bot self report errors
This commit is contained in:
		
							parent
							
								
									21c23daeba
								
							
						
					
					
						commit
						ea186fac4d
					
				
					 1 changed files with 14 additions and 10 deletions
				
			
		| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
import random
 | 
					import random
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
import typing
 | 
					import typing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import bs4
 | 
					import bs4
 | 
				
			||||||
| 
						 | 
					@ -26,9 +27,9 @@ class ApiWrapper:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # this is the entry point for the api calls
 | 
					    # this is the entry point for the api calls
 | 
				
			||||||
    # if you add another api, make sure there is a match here
 | 
					    # if you add another api, make sure there is a match here
 | 
				
			||||||
    # this could have used match - case statement, but python 3.9
 | 
					 | 
				
			||||||
    def call(self, api: str, data: typing.Union[str, None],
 | 
					    def call(self, api: str, data: typing.Union[str, None],
 | 
				
			||||||
             message: str) -> str:
 | 
					             message: str) -> str:
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
            match api:
 | 
					            match api:
 | 
				
			||||||
                case 'img_url': return self.format_img(data)
 | 
					                case 'img_url': return self.format_img(data)
 | 
				
			||||||
                case 'gif': return self.get_gif()
 | 
					                case 'gif': return self.get_gif()
 | 
				
			||||||
| 
						 | 
					@ -38,6 +39,9 @@ class ApiWrapper:
 | 
				
			||||||
                case 'anek': return self.get_anek()
 | 
					                case 'anek': return self.get_anek()
 | 
				
			||||||
                case 'y_search': return self.y_search(message)
 | 
					                case 'y_search': return self.y_search(message)
 | 
				
			||||||
                case _: return self.FAILED
 | 
					                case _: return self.FAILED
 | 
				
			||||||
 | 
					        except Exception as e:
 | 
				
			||||||
 | 
					            sys.stderr.write(e)
 | 
				
			||||||
 | 
					            return self.FAILED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __sanitize_search(self, message: str) -> str:
 | 
					    def __sanitize_search(self, message: str) -> str:
 | 
				
			||||||
        """Removes one of each of the search tokens from the query
 | 
					        """Removes one of each of the search tokens from the query
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue