-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
91 lines (62 loc) · 2.16 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
import time
import handlers
from aiogram import executor, types
from aiogram.types import ReplyKeyboardMarkup, ReplyKeyboardRemove
from data import config
from loader import dp, db, bot
import filters
import logging
filters.setup(dp)
WEBAPP_HOST = "0.0.0.0"
WEBAPP_PORT = int(os.environ.get("PORT", 5000))
user_message = 'userAbu'
admin_message = 'Админ'
# @dp.message_handler(commands='start')
# async def cmd_start(message: types.Message):
#
# markup = ReplyKeyboardMarkup(resize_keyboard=True)
#
# markup.row(user_message, admin_message)
#
# await message.answer('''Assalomu Alaykum menu kormoqchi bolsangiz /menu ni bosing
# ''')
@dp.message_handler(text=user_message)
async def user_mode(message: types.Message):
cid = message.chat.id
if cid in config.ADMINS:
config.ADMINS.remove(cid)
await message.answer('Включен пользовательский режим.', reply_markup=ReplyKeyboardRemove())
@dp.message_handler(text=admin_message)
async def admin_mode(message: types.Message):
cid = message.chat.id
if cid not in config.ADMINS:
config.ADMINS.append(cid)
await message.answer('Включен админский режим.', reply_markup=ReplyKeyboardRemove())
async def send_messange():
logging.basicConfig(level=logging.INFO)
await bot.send_message(chat_id=452785654,text='111111')
async def on_startup(dp):
logging.basicConfig(level=logging.INFO)
db.create_tables()
await bot.delete_webhook()
await bot.set_webhook(config.WEBHOOK_URL)
async def on_shutdown():
logging.warning("Shutting down..")
await bot.delete_webhook()
await dp.storage.close()
await dp.storage.wait_closed()
logging.warning("Bot down")
if __name__ == '__main__':
if "HEROKU" in list(os.environ.keys()):
executor.start_webhook(
dispatcher=dp,
webhook_path=config.WEBHOOK_PATH,
on_startup=on_startup,
on_shutdown=on_shutdown,
skip_updates=True,
host=WEBAPP_HOST,
port=WEBAPP_PORT,
)
else:
executor.start_polling(dp, on_startup=on_startup, skip_updates=False)