remove mute/unmute, fix vouch callback
This commit is contained in:
@@ -1,8 +1,30 @@
|
||||
from tgbot.api import send_message, forward_message, delete_message, \
|
||||
approve_chat_join_request, unmute_member, edit_replymarkup, get_chat
|
||||
approve_chat_join_request, edit_replymarkup, get_chat
|
||||
from tgbot.storage import Profile, storage
|
||||
|
||||
|
||||
def update_button(chat_id, member_id, text='❤️'):
|
||||
print('update reply markup')
|
||||
prevmsg_id = storage.get(f'btn-{chat_id}-{member_id}')
|
||||
if prevmsg_id:
|
||||
premsg_id = prevmsg_id.decode('utf-8')
|
||||
newcomer = Profile.get(member_id)
|
||||
amount = len(newcomer['parents']) + 1
|
||||
text += f' {amount}'
|
||||
rm = {
|
||||
"inline_keyboard": [
|
||||
[
|
||||
{
|
||||
"text": text,
|
||||
"callback_data": 'vouch' + member_id
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
r = edit_replymarkup(chat_id, prevmsg_id, reply_markup=rm)
|
||||
print(r)
|
||||
|
||||
|
||||
def handle_button(callback_query):
|
||||
# получаем профиль нажавшего кнопку
|
||||
actor_id = str(callback_query['from']['id'])
|
||||
@@ -39,27 +61,4 @@ def handle_button(callback_query):
|
||||
r = approve_chat_join_request(chat_id, newcomer_id)
|
||||
print(r)
|
||||
|
||||
print('update reply markup')
|
||||
prevmsg_id = storage.get(f'btn-{chat_id}-{newcomer_id}').decode('utf-8')
|
||||
amount = len(newcomer['parents']) + 1
|
||||
rm = {
|
||||
"inline_keyboard": [
|
||||
[
|
||||
{
|
||||
"text": '❤️' + f'({amount})',
|
||||
"callback_data": 'vouch' + newcomer_id
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
r = edit_replymarkup(chat_id, premsg_id, reply_markup=rm)
|
||||
print(r)
|
||||
|
||||
if not r.get('ok'):
|
||||
print('getting chat permissions')
|
||||
r = get_chat(chat_id)
|
||||
print(r)
|
||||
perms = r['result']['permissions']
|
||||
print('try to unmute newcomer')
|
||||
r = unmute_member(chat_id, newcomer_id, chat_permissions=perms)
|
||||
print(r)
|
||||
update_button(chat_id, newcomer_id)
|
Reference in New Issue
Block a user