new cfg storing method

This commit is contained in:
Andrew Linim 2024-11-04 18:28:47 +03:00
parent 133e195a19
commit e563a1aae9
5 changed files with 12 additions and 9 deletions

Binary file not shown.

Binary file not shown.

3
api.py
View file

@ -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:

View file

@ -2,4 +2,10 @@ bot = "" # bot api-key from next
api = "" # google api key
cx = "" # google cx
# tutorial for api&cx - https://pypi.org/project/Google-Images-Search/
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/

10
main.py
View file

@ -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 "!"
@ -38,7 +34,7 @@ class Client(commands.CommandsClient):
arg += f"{word} "
if count>10:
if count > 10:
toomanyimages = True
else:
toomanyimages = False
@ -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())