diff --git a/bot.py b/bot.py index a5656e7..47a608a 100644 --- a/bot.py +++ b/bot.py @@ -1,9 +1,9 @@ import logging -from aiogram import executor +from aiogram import executor, Bot, Dispatcher from create_bot import dp import handlers import json - +from global_conf import CONFIG @@ -38,6 +38,8 @@ logging.getLogger("aiogram").addFilter(filter_grammar_messages) # start_help.register_handlers_StartHelp(dp) if __name__ == '__main__': + #print(CONFIG) + executor.start_polling(dp, skip_updates=True) diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..d3c0ac4 --- /dev/null +++ b/config.yaml @@ -0,0 +1,17 @@ +--- +databaso: + host: 'https://arango.guaranteedstruggle.host' + user: root + pass: stolendick527 + base: pipisa + collection: dicks + +telegram_token: 5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w +telegram_admins_ids: +- 317051301 # hogweed1 +- 226765676 # blackjack +- 94830892 # viktorRMI + +openai: + token: 5947963644:AAF_GKgMmU5ovqMpc1KXIpcf4aN0JMyKPqc + api_key: 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 ## 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 \ No newline at end of file diff --git a/create_bot.py b/create_bot.py index 247163b..a272f87 100644 --- a/create_bot.py +++ b/create_bot.py @@ -1,7 +1,8 @@ from aiogram import Bot, Dispatcher +from global_conf import CONFIG -API_TOKEN = '5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w' +API_TOKEN = '6472915685:AAHPvgrQoqG7DxtfbnHWPe3Lfild-CGJ1j8' -bot = Bot(token=API_TOKEN, parse_mode="HTML") +bot = Bot(token=CONFIG['telegram_token'], parse_mode="HTML") dp = Dispatcher(bot) \ No newline at end of file diff --git a/global_conf.py b/global_conf.py new file mode 100644 index 0000000..38fcb3f --- /dev/null +++ b/global_conf.py @@ -0,0 +1,6 @@ +import yaml + + + +with open("config.yaml", 'r') as f: + CONFIG = yaml.load(f, Loader=yaml.Loader) diff --git a/handlers/__init__.py b/handlers/__init__.py index 1ac1416..34a19bf 100644 --- a/handlers/__init__.py +++ b/handlers/__init__.py @@ -3,6 +3,4 @@ from handlers import pipisa from handlers import start_help from handlers import time_new_year -from handlers import sendalarm -#from handlers import davinci diff --git a/handlers/davinci.py b/handlers/davinci.py index 7a90c67..1fd3fb1 100644 --- a/handlers/davinci.py +++ b/handlers/davinci.py @@ -1,14 +1,14 @@ import openai -from aiogram import types, Dispatcher +from aiogram import types from create_bot import dp, bot import logging +from global_conf import CONFIG -token = '5947963644:AAF_GKgMmU5ovqMpc1KXIpcf4aN0JMyKPqc' -#openai.api_key = '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' -openai.api_key = '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' -ban_comands = ['/dick','/topdick'] +token = CONFIG['openai']['token'] +openai.api_key = CONFIG['openai']['api_key'] +ban_comands = ['/dick','/topdick'] # Image_promt =['тупица сгенерируй','тупица сгенерируй картинку',\ # 'тупица отправь картинку', 'тупица отправь картинку'] diff --git a/handlers/pipisa.py b/handlers/pipisa.py index d54e460..0347ff4 100644 --- a/handlers/pipisa.py +++ b/handlers/pipisa.py @@ -1,17 +1,17 @@ -from aiogram import types, Dispatcher +from aiogram import types from create_bot import bot, dp -#from sqdb import user, session import random from random import randint import datetime from dicktxt import ForReadDict from pipisa_functions import pipisa_time +from global_conf import CONFIG #### https://docs.python-arango.com/en/main/ from arango import ArangoClient -admins = [317051301, 226765676] +admins = CONFIG['telegram_admins_ids'] @dp.message_handler(commands=["dick"]) @@ -21,9 +21,13 @@ async def up_dick(message: types.Message): if message.from_user.id in admins or message.chat.type != 'private': - arango_client = ArangoClient(hosts='https://arango.guaranteedstruggle.host') - pipisa_db = arango_client.db('pipisa', username='root', password='stolendick527') - dicks_collection = pipisa_db.collection('dicks') + arango_client = ArangoClient(hosts=CONFIG['databaso']['host'] ) + pipisa_db = arango_client.db( + CONFIG['databaso']['base'], + username=CONFIG['databaso']['user'], + password=CONFIG['databaso']['pass'] + ) + dicks_collection = pipisa_db.collection(CONFIG['databaso']['collection']) #### TODO уплатить нолог с 100 см для самого нищего @@ -171,9 +175,13 @@ async def up_dick(message: types.Message): async def send_topchat(message: types.Message): if message.from_user.id in admins or message.chat.type != 'private': - arango_client = ArangoClient(hosts='https://arango.guaranteedstruggle.host') - pipisa_db = arango_client.db('pipisa', username='root', password='stolendick527') - dicks_collection = pipisa_db.collection('dicks') + arango_client = ArangoClient(hosts=CONFIG['databaso']['host'] ) + pipisa_db = arango_client.db( + CONFIG['databaso']['base'], + username=CONFIG['databaso']['user'], + password=CONFIG['databaso']['pass'] + ) + dicks_collection = pipisa_db.collection(CONFIG['databaso']['collection']) try: dicks = dicks_collection.find({'chat_id': message.chat.id}, skip=0, limit=1100) @@ -209,9 +217,13 @@ async def send_topchat(message: types.Message): async def send_global_top(message: types.Message): - arango_client = ArangoClient(hosts='https://arango.guaranteedstruggle.host') - pipisa_db = arango_client.db('pipisa', username='root', password='stolendick527') - dicks_collection = pipisa_db.collection('dicks') + arango_client = ArangoClient(hosts=CONFIG['databaso']['host'] ) + pipisa_db = arango_client.db( + CONFIG['databaso']['base'], + username=CONFIG['databaso']['user'], + password=CONFIG['databaso']['pass'] + ) + dicks_collection = pipisa_db.collection(CONFIG['databaso']['collection']) try: dicks = dicks_collection.all( ) diff --git a/handlers/sendalarm.py b/handlers/sendalarm.py deleted file mode 100644 index 9869eb9..0000000 --- a/handlers/sendalarm.py +++ /dev/null @@ -1,24 +0,0 @@ - -from create_bot import dp, bot -from aiogram import types, Dispatcher - -@dp.message_handler(commands=['sendall']) -async def sendall(message: types.Message): - print('команда прошла') - if message.chat.type == 'private': - if message.from_user.id == 226765676: - text = message.text[9:] - try: - chats_id = -1001355646177 - - try: - await bot.send_message(chats_id, text) - except: - print('вероятно бота нет в чате') - await bot.send_message(message.from_user.id, 'Сообщение успешно отправлено во все чаты') - except: - print('eror sendall') - - -# def register_handlers_test(dp: Dispatcher): -# dp.register_message_handler(send_welcome) \ No newline at end of file diff --git a/handlers/start_help.py b/handlers/start_help.py index 0c9f235..c61e494 100644 --- a/handlers/start_help.py +++ b/handlers/start_help.py @@ -1,4 +1,4 @@ -from aiogram import types, Dispatcher +from aiogram import types from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton from create_bot import dp, bot diff --git a/requairements.txt b/requairements.txt index 4e1c440..eb4a969 100644 --- a/requairements.txt +++ b/requairements.txt @@ -1,2 +1,3 @@ aiogram -python-arango \ No newline at end of file +python-arango +pyyaml \ No newline at end of file