remove more
This commit is contained in:
parent
eb9540377b
commit
1f81b751bb
24
api/index.py
24
api/index.py
|
@ -57,7 +57,7 @@ async def handle(req):
|
||||||
)
|
)
|
||||||
welcome_msg_id = r.json()['result']['message_id']
|
welcome_msg_id = r.json()['result']['message_id']
|
||||||
print(f'welcome message id: {welcome_msg_id}')
|
print(f'welcome message id: {welcome_msg_id}')
|
||||||
newcomers[member_id] = f'newcomer{welcome_msg_id}'
|
newcomers[member_id] = f'newcomer:{msg["message_id"]}:{welcome_msg_id}'
|
||||||
elif 'text' in msg:
|
elif 'text' in msg:
|
||||||
chat_id = str(msg['chat']['id'])
|
chat_id = str(msg['chat']['id'])
|
||||||
member_id = str(msg['from']['id'])
|
member_id = str(msg['from']['id'])
|
||||||
|
@ -67,13 +67,13 @@ async def handle(req):
|
||||||
print('watched newcomer')
|
print('watched newcomer')
|
||||||
answer = msg['text']
|
answer = msg['text']
|
||||||
if BUTTON_OK.lower() in answer.lower():
|
if BUTTON_OK.lower() in answer.lower():
|
||||||
print('found answer')
|
print('found answer, cleanup')
|
||||||
print('deleting welcome msg')
|
[_, enter_msg, welcome_msg] = newcomers[member_id].split(':')
|
||||||
r = delete_message(CHAT_ID, newcomers[member_id].replace('newcomer', ''))
|
r = delete_message(CHAT_ID, welcome_msg)
|
||||||
print(r.json())
|
print(r.json())
|
||||||
newcomers[member_id] = None
|
newcomers[member_id] = None
|
||||||
else:
|
else:
|
||||||
print('deleting some message')
|
print('remove some message')
|
||||||
r = delete_message(CHAT_ID, msg['message_id'])
|
r = delete_message(CHAT_ID, msg['message_id'])
|
||||||
print(r.json())
|
print(r.json())
|
||||||
else:
|
else:
|
||||||
|
@ -87,16 +87,20 @@ async def handle(req):
|
||||||
member_id = str(callback_query['from']['id'])
|
member_id = str(callback_query['from']['id'])
|
||||||
callback_data = callback_query['data']
|
callback_data = callback_query['data']
|
||||||
if callback_data == BUTTON_NO:
|
if callback_data == BUTTON_NO:
|
||||||
print('deleting welcome msg')
|
print('wrong answer, cleanup')
|
||||||
r = delete_message(CHAT_ID, newcomers[member_id].replace('newcomer', ''))
|
[_, enter_msg, welcome_msg] = newcomers[member_id].split(':')
|
||||||
|
r = delete_message(CHAT_ID, enter_msg)
|
||||||
|
print(r.json())
|
||||||
|
r = delete_message(CHAT_ID, welcome_msg)
|
||||||
print(r.json())
|
print(r.json())
|
||||||
newcomers[member_id] = None
|
newcomers[member_id] = None
|
||||||
print('wrong answer')
|
print('ban member')
|
||||||
r = ban_member(CHAT_ID, member_id)
|
r = ban_member(CHAT_ID, member_id)
|
||||||
print(r.json())
|
print(r.json())
|
||||||
elif callback_data == BUTTON_OK:
|
elif callback_data == BUTTON_OK:
|
||||||
print('proper answer')
|
print('proper answer, cleanup')
|
||||||
r = delete_message(CHAT_ID, newcomers[member_id].replace('newcomer', ''))
|
[_, enter_msg, welcome_msg] = newcomers[member_id].split(':')
|
||||||
|
r = delete_message(CHAT_ID, welcome_msg)
|
||||||
print(r.json())
|
print(r.json())
|
||||||
newcomers[member_id] = None
|
newcomers[member_id] = None
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user