0.0.12-fixes
This commit is contained in:
@@ -12,10 +12,13 @@ from bot.handlers.callback_unlink import handle_unlink
|
||||
from bot.handlers.handle_startup import handle_startup
|
||||
from bot.api import register_webhook, send_message
|
||||
from bot.config import FEEDBACK_CHAT_ID
|
||||
from bot.state import State
|
||||
|
||||
app = Sanic(name="welcomecenter")
|
||||
app.config.REGISTERED = False
|
||||
|
||||
state = State()
|
||||
|
||||
|
||||
@app.get('/')
|
||||
async def register(req):
|
||||
@@ -36,33 +39,38 @@ async def handle(req):
|
||||
# видимые сообщения
|
||||
msg = update.get('message', update.get('edited_message'))
|
||||
if msg:
|
||||
if 'edited_message' in update:
|
||||
msg['edit'] = True
|
||||
if 'text' in msg:
|
||||
if msg['chat']['id'] == msg['from']['id']:
|
||||
print('private chat message')
|
||||
if msg['text'].startswith('/my'):
|
||||
handle_command_my(msg)
|
||||
elif msg['text'].startswith('/unlink'):
|
||||
handle_unlink(msg)
|
||||
else:
|
||||
handle_feedback(msg)
|
||||
elif str(msg['chat']['id']) == FEEDBACK_CHAT_ID:
|
||||
print('feedback chat message')
|
||||
if 'reply_to_message' in msg:
|
||||
handle_answer(msg)
|
||||
elif msg['text'] == '/graph':
|
||||
await handle_command_graph(msg)
|
||||
elif msg['text'].startswith('/ask'):
|
||||
handle_command_ask(msg)
|
||||
msg['edit'] = 'edited_message' in update
|
||||
|
||||
if msg['chat']['id'] == msg['from']['id']:
|
||||
# сообщения в личке с ботом
|
||||
print('private chat message')
|
||||
if msg['text'].startswith('/my'):
|
||||
handle_command_my(msg)
|
||||
elif msg['text'].startswith('/unlink'):
|
||||
handle_unlink(msg)
|
||||
else:
|
||||
handle_default(msg)
|
||||
elif 'new_chat_member' in msg:
|
||||
handle_join(msg)
|
||||
elif 'left_chat_member' in msg:
|
||||
handle_left(msg)
|
||||
handle_feedback(msg, state)
|
||||
|
||||
elif str(msg['chat']['id']) == FEEDBACK_CHAT_ID:
|
||||
# сообщения из группы обратной связи
|
||||
print('feedback chat message')
|
||||
if 'reply_to_message' in msg:
|
||||
handle_answer(msg)
|
||||
elif msg['text'] == '/graph':
|
||||
await handle_command_graph(msg)
|
||||
elif msg['text'].startswith('/ask'):
|
||||
handle_command_ask(msg)
|
||||
|
||||
else:
|
||||
print('message without text')
|
||||
# сообщения из всех остальных групп
|
||||
cid = msg['chat']['id']
|
||||
print(f'group {cid} chat message')
|
||||
if 'text' in msg:
|
||||
handle_default(msg)
|
||||
elif 'new_chat_member' in msg:
|
||||
handle_join(msg)
|
||||
elif 'left_chat_member' in msg:
|
||||
handle_left(msg)
|
||||
|
||||
# кнопки
|
||||
elif 'callback_query' in update:
|
||||
@@ -76,10 +84,6 @@ async def handle(req):
|
||||
elif 'chat_join_request' in update:
|
||||
print('chat join request')
|
||||
handle_join_request(update['chat_join_request'])
|
||||
|
||||
# wtf
|
||||
else:
|
||||
print('unhandled update')
|
||||
|
||||
|
||||
except Exception:
|
||||
|
Reference in New Issue
Block a user