some cosmetics and case statements
This commit is contained in:
parent
35da34bc8c
commit
c4f65650b9
3 changed files with 16 additions and 12 deletions
|
@ -1,5 +1,3 @@
|
|||
""" Some functions for api calls """
|
||||
|
||||
import json
|
||||
import random
|
||||
import re
|
||||
|
@ -31,14 +29,15 @@ class ApiWrapper:
|
|||
# this could have used match - case statement, but python 3.9
|
||||
def call(self, api: str, data: typing.Union[str, None],
|
||||
message: str) -> str:
|
||||
if api == 'img_url': return self.format_img(data)
|
||||
elif api == 'gif': return self.get_gif()
|
||||
elif api == 'kmp': return self.get_kmp()
|
||||
elif api == 'fga': return self.get_fga()
|
||||
elif api == 'fakenews': return self.get_fakenews()
|
||||
elif api == 'anek': return self.get_anek()
|
||||
elif api == 'y_search': return self.y_search(message)
|
||||
return self.FAILED
|
||||
match api:
|
||||
case 'img_url': return self.format_img(data)
|
||||
case 'gif': return self.get_gif()
|
||||
case 'kmp': return self.get_kmp()
|
||||
case 'fga': return self.get_fga()
|
||||
case 'fakenews': return self.get_fakenews()
|
||||
case 'anek': return self.get_anek()
|
||||
case 'y_search': return self.y_search(message)
|
||||
case _: return self.FAILED
|
||||
|
||||
def __sanitize_search(self, message: str) -> str:
|
||||
"""Removes one of each of the search tokens from the query
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue