new cfg storing method
This commit is contained in:
parent
133e195a19
commit
e563a1aae9
5 changed files with 12 additions and 9 deletions
BIN
__pycache__/api.cpython-312.pyc
Normal file
BIN
__pycache__/api.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/creds.cpython-312.pyc
Normal file
BIN
__pycache__/creds.cpython-312.pyc
Normal file
Binary file not shown.
3
api.py
3
api.py
|
@ -1,12 +1,13 @@
|
|||
from google_images_search import GoogleImagesSearch
|
||||
import creds
|
||||
from creds import gimgsettings
|
||||
|
||||
gis = GoogleImagesSearch(creds.api, creds.cx)
|
||||
|
||||
def get_img(query, count):
|
||||
gis.search(search_params= {
|
||||
'q': query,
|
||||
'safe': 'active',
|
||||
'safe': gimgsettings['safesearch'],
|
||||
'num': count,
|
||||
})
|
||||
if count == 1:
|
||||
|
|
6
creds.py
6
creds.py
|
@ -2,4 +2,10 @@ bot = "" # bot api-key from next
|
|||
api = "" # google api key
|
||||
cx = "" # google cx
|
||||
|
||||
gimgsettings = {
|
||||
"usestoplist": True, # use stop-list
|
||||
"stoplist": ["пенис", "хуй", "шлюха", "penis", "pride", 'lgbt', "лгбт", "прайд", "dick", "1488", "swastika", "свастика", "свастон"],
|
||||
"safesearch": "high" # safe search mode. values: active|high|medium|off|safeUndefined
|
||||
}
|
||||
|
||||
# tutorial for api & cx - https://pypi.org/project/Google-Images-Search/
|
8
main.py
8
main.py
|
@ -2,14 +2,10 @@ import asyncio
|
|||
import aiohttp
|
||||
import next
|
||||
import creds
|
||||
from creds import gimgsettings
|
||||
from next.ext import commands
|
||||
from api import get_img
|
||||
|
||||
gimgsettings = {
|
||||
"usestoplist": True,
|
||||
"stoplist": ["пенис", "хуй", "шлюха", "penis", "pride", 'lgbt', "лгбт", "прайд", "dick", "1488", "swastika", "свастика", "свастон"]
|
||||
}
|
||||
|
||||
class Client(commands.CommandsClient):
|
||||
async def get_prefix(self, message: next.Message):
|
||||
return "!"
|
||||
|
@ -58,7 +54,7 @@ class Client(commands.CommandsClient):
|
|||
async def main():
|
||||
async with aiohttp.ClientSession() as session:
|
||||
client = Client(session, creds.bot)
|
||||
print("Running GIMG")
|
||||
print("Running GImages")
|
||||
await client.start()
|
||||
|
||||
asyncio.run(main())
|
||||
|
|
Loading…
Reference in a new issue