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
|
from google_images_search import GoogleImagesSearch
|
||||||
import creds
|
import creds
|
||||||
|
from creds import gimgsettings
|
||||||
|
|
||||||
gis = GoogleImagesSearch(creds.api, creds.cx)
|
gis = GoogleImagesSearch(creds.api, creds.cx)
|
||||||
|
|
||||||
def get_img(query, count):
|
def get_img(query, count):
|
||||||
gis.search(search_params= {
|
gis.search(search_params= {
|
||||||
'q': query,
|
'q': query,
|
||||||
'safe': 'active',
|
'safe': gimgsettings['safesearch'],
|
||||||
'num': count,
|
'num': count,
|
||||||
})
|
})
|
||||||
if count == 1:
|
if count == 1:
|
||||||
|
|
8
creds.py
8
creds.py
|
@ -2,4 +2,10 @@ bot = "" # bot api-key from next
|
||||||
api = "" # google api key
|
api = "" # google api key
|
||||||
cx = "" # google cx
|
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
10
main.py
|
@ -2,14 +2,10 @@ import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import next
|
import next
|
||||||
import creds
|
import creds
|
||||||
|
from creds import gimgsettings
|
||||||
from next.ext import commands
|
from next.ext import commands
|
||||||
from api import get_img
|
from api import get_img
|
||||||
|
|
||||||
gimgsettings = {
|
|
||||||
"usestoplist": True,
|
|
||||||
"stoplist": ["пенис", "хуй", "шлюха", "penis", "pride", 'lgbt', "лгбт", "прайд", "dick", "1488", "swastika", "свастика", "свастон"]
|
|
||||||
}
|
|
||||||
|
|
||||||
class Client(commands.CommandsClient):
|
class Client(commands.CommandsClient):
|
||||||
async def get_prefix(self, message: next.Message):
|
async def get_prefix(self, message: next.Message):
|
||||||
return "!"
|
return "!"
|
||||||
|
@ -38,7 +34,7 @@ class Client(commands.CommandsClient):
|
||||||
arg += f"{word} "
|
arg += f"{word} "
|
||||||
|
|
||||||
|
|
||||||
if count>10:
|
if count > 10:
|
||||||
toomanyimages = True
|
toomanyimages = True
|
||||||
else:
|
else:
|
||||||
toomanyimages = False
|
toomanyimages = False
|
||||||
|
@ -58,7 +54,7 @@ class Client(commands.CommandsClient):
|
||||||
async def main():
|
async def main():
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
client = Client(session, creds.bot)
|
client = Client(session, creds.bot)
|
||||||
print("Running GIMG")
|
print("Running GImages")
|
||||||
await client.start()
|
await client.start()
|
||||||
|
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|
Loading…
Reference in a new issue