add cancel button in private messages

This commit is contained in:
Simone Baracchi 2019-08-04 19:53:36 +02:00
parent 186bb6f682
commit fb0cfc2632
2 changed files with 10 additions and 2 deletions

View File

@ -520,7 +520,12 @@ How can I help you?"""
options['Roll dices (shortcut: /roll <dice>)'] = 'roll'
options['Roll dices secretly (shortcut: /gmroll)'] = 'gmroll'
options['Go to official site ->'] = {'url': 'https://github.com/simonebaracchi/rpgbot'}
subopts = OrderedDict()
subopts['Go to official site ->'] = {'url': 'https://github.com/simonebaracchi/rpgbot'}
subopts['Cancel'] = 'cancel'
options['dummy3'] = subopts
handler.send('How can I help you?', options=options, allowedit=True)
else:
# Game is started in the group!

View File

@ -106,7 +106,10 @@ class MessageHandler(telepot.helper.ChatHandler):
else:
sublist = []
for key, subvalue in value.items():
sublist.append(InlineKeyboardButton(text=key, callback_data=subvalue))
if isinstance(subvalue, dict) and 'url' in subvalue:
sublist.append(InlineKeyboardButton(text=key, url=subvalue['url']))
else:
sublist.append(InlineKeyboardButton(text=key, callback_data=subvalue))
buttons.append(sublist)
else:
buttons.append([InlineKeyboardButton(text=key, callback_data=value)])