Implemented button to delete all commands stored by BotFather
This commit is contained in:
parent
a4079cf91d
commit
34cf987aa7
@ -11,7 +11,7 @@ __author__ = "Davide Testa"
|
|||||||
__email__ = "davide@davte.it"
|
__email__ = "davide@davte.it"
|
||||||
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
|
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
|
||||||
__license__ = "GNU General Public License v3.0"
|
__license__ = "GNU General Public License v3.0"
|
||||||
__version__ = "2.5.8"
|
__version__ = "2.5.9"
|
||||||
__maintainer__ = "Davide Testa"
|
__maintainer__ = "Davide Testa"
|
||||||
__contact__ = "t.me/davte"
|
__contact__ = "t.me/davte"
|
||||||
|
|
||||||
|
@ -1412,12 +1412,63 @@ async def _father_button(bot: Bot, user_record: OrderedDict,
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
elif command == 'del':
|
||||||
|
if not Confirmator.get('del_bot_father_commands',
|
||||||
|
confirm_timedelta=3
|
||||||
|
).confirm(user_record['id']):
|
||||||
|
return bot.get_message(
|
||||||
|
'admin', 'confirm',
|
||||||
|
language=language
|
||||||
|
)
|
||||||
|
stored_commands = await bot.getMyCommands()
|
||||||
|
if not len(stored_commands):
|
||||||
|
text = bot.get_message(
|
||||||
|
'admin', 'father_command', 'del', 'no_change',
|
||||||
|
language=language
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
if isinstance(
|
||||||
|
await bot.setMyCommands([]),
|
||||||
|
Exception
|
||||||
|
):
|
||||||
|
text = bot.get_message(
|
||||||
|
'admin', 'father_command', 'del', 'error',
|
||||||
|
language=language
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
text = bot.get_message(
|
||||||
|
'admin', 'father_command', 'del', 'done',
|
||||||
|
language=language
|
||||||
|
)
|
||||||
|
reply_markup = make_inline_keyboard(
|
||||||
|
[
|
||||||
|
make_button(
|
||||||
|
text=bot.get_message('admin', 'father_command', 'back',
|
||||||
|
language=language),
|
||||||
|
prefix='father:///',
|
||||||
|
delimiter='|',
|
||||||
|
data=['main']
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
elif command == 'get':
|
elif command == 'get':
|
||||||
commands = await bot.getMyCommands()
|
commands = await bot.getMyCommands()
|
||||||
text = '<code>' + '\n'.join(
|
if len(commands) == 0:
|
||||||
|
commands = bot.get_message(
|
||||||
|
'admin', 'father_command', 'get', 'empty',
|
||||||
|
language=language,
|
||||||
|
commands=commands
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
commands = '<code>' + '\n'.join(
|
||||||
"{c[command]} - {c[description]}".format(c=command)
|
"{c[command]} - {c[description]}".format(c=command)
|
||||||
for command in commands
|
for command in commands
|
||||||
) + '</code>'
|
) + '</code>'
|
||||||
|
text = bot.get_message(
|
||||||
|
'admin', 'father_command', 'get', 'panel',
|
||||||
|
language=language,
|
||||||
|
commands=commands
|
||||||
|
)
|
||||||
reply_markup = make_inline_keyboard(
|
reply_markup = make_inline_keyboard(
|
||||||
[
|
[
|
||||||
make_button(
|
make_button(
|
||||||
|
@ -95,6 +95,20 @@ default_admin_messages = {
|
|||||||
'en': "↩️ Back",
|
'en': "↩️ Back",
|
||||||
'it': "↩️ Indietro",
|
'it': "↩️ Indietro",
|
||||||
},
|
},
|
||||||
|
'del': {
|
||||||
|
'done': {
|
||||||
|
'en': "✅ Commands deleted",
|
||||||
|
'it': "✅ Comandi rimossi",
|
||||||
|
},
|
||||||
|
'error': {
|
||||||
|
'en': "Something went wrong 😕",
|
||||||
|
'it': "Qualcosa è andato storto 😕",
|
||||||
|
},
|
||||||
|
'no_change': {
|
||||||
|
'en': "❌ No command stored",
|
||||||
|
'it': "❌ Nessun comando salvato",
|
||||||
|
},
|
||||||
|
},
|
||||||
'description': {
|
'description': {
|
||||||
'en': "Edit the @BotFather commands",
|
'en': "Edit the @BotFather commands",
|
||||||
'it': "Modifica i comandi con @BotFather",
|
'it': "Modifica i comandi con @BotFather",
|
||||||
@ -103,6 +117,20 @@ default_admin_messages = {
|
|||||||
'en': "❌ Error! ❌",
|
'en': "❌ Error! ❌",
|
||||||
'it': "❌ Errore! ❌",
|
'it': "❌ Errore! ❌",
|
||||||
},
|
},
|
||||||
|
'get': {
|
||||||
|
'empty': {
|
||||||
|
'en': "No command set yet. You may use <code>✏️ Change</code> "
|
||||||
|
"button",
|
||||||
|
'it': "Nessun comando impostato ancora. Puoi usare il bottone "
|
||||||
|
"<code>✏️ Modifica</code>",
|
||||||
|
},
|
||||||
|
'panel': {
|
||||||
|
'en': "🤖 <b>BotFather commands</b> ℹ️\n\n"
|
||||||
|
"{commands}",
|
||||||
|
'it': "🤖 <b>Comandi su BotFather</b> ℹ️\n\n"
|
||||||
|
"{commands}",
|
||||||
|
},
|
||||||
|
},
|
||||||
'modes': [
|
'modes': [
|
||||||
{
|
{
|
||||||
'id': "get",
|
'id': "get",
|
||||||
@ -128,6 +156,18 @@ default_admin_messages = {
|
|||||||
'it': "Modifica i comandi salvati su @BotFather"
|
'it': "Modifica i comandi salvati su @BotFather"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'id': "del",
|
||||||
|
'name': {
|
||||||
|
'en': "Delete",
|
||||||
|
'it': "Cancella"
|
||||||
|
},
|
||||||
|
'symbol': "🗑",
|
||||||
|
'description': {
|
||||||
|
'en': "Delete commands stored by @BotFather",
|
||||||
|
'it': "Cancella i comandi salvati su @BotFather"
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'id': "settings",
|
'id': "settings",
|
||||||
'name': {
|
'name': {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user