From e563a1aae948e6849778f656aa21230172bb3ee5 Mon Sep 17 00:00:00 2001 From: Andrew Linim Date: Mon, 4 Nov 2024 18:28:47 +0300 Subject: [PATCH] new cfg storing method --- __pycache__/api.cpython-312.pyc | Bin 0 -> 921 bytes __pycache__/creds.cpython-312.pyc | Bin 0 -> 541 bytes api.py | 3 ++- creds.py | 8 +++++++- main.py | 10 +++------- 5 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 __pycache__/api.cpython-312.pyc create mode 100644 __pycache__/creds.cpython-312.pyc diff --git a/__pycache__/api.cpython-312.pyc b/__pycache__/api.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0093b9976768cf568166b358818a3f42d6273ee6 GIT binary patch literal 921 zcma)4L2DC16n--u&qQNO+w8fctZ8(kf346onX zjHjBR)bjW~gZRj9I9Bg#A@Q{6g3_w@j}q4Z|J;%|GCMxYKFi z1Moo^$0Sw1usz)uHuk?P=s8jgKI!e9Q%wSgdH3w5Lw1{Ot36Pcei`zjeYjz_Rhgn zc2FcLS{f=kI`btZM1dbbv)5VMQqTs{QDu#if{|wC&AfR}njf*)G~j`L-L`i`0Dew} ztB^0j`2q)T00eaag}MO6x(Fp3K>3{jBT#uO)usNF8f6b^&RV6NE0wKWVQ=5)l`{F7 z1HDI^MQoK<3spCl)^-xka;94BKkV-%Tr0V0n5aATZkatGn++KW|GnMnWVdziRN=QV`IlA$oFx_Chx&HcL#qL;Jrp0cd*ki zyO0x&!iJ;Uh%`(OL2}3Kv*?P`g+UwL_il25z>}!FoJoQpjFt6)G*<5N5{VDQGX>1Y W|A=7D5yv;;zo+C`aX916^Xm(XSH3m? literal 0 HcmV?d00001 diff --git a/api.py b/api.py index eeea09b..e53320f 100644 --- a/api.py +++ b/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: diff --git a/creds.py b/creds.py index 8e2518e..70ce03c 100644 --- a/creds.py +++ b/creds.py @@ -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/ \ No newline at end of file +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/ \ No newline at end of file diff --git a/main.py b/main.py index 0e57523..63a1bbe 100644 --- a/main.py +++ b/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 "!" @@ -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())