Temp
This commit is contained in:
@@ -1059,30 +1059,77 @@ def init(telegram_bot: Bot,
|
|||||||
'cancelled',
|
'cancelled',
|
||||||
db.types.integer
|
db.types.integer
|
||||||
)
|
)
|
||||||
|
for exception in [
|
||||||
allowed_during_maintenance = [
|
|
||||||
get_maintenance_exception_criterion(telegram_bot, command)
|
get_maintenance_exception_criterion(telegram_bot, command)
|
||||||
for command in ['stop', 'restart', 'maintenance']
|
for command in ['stop', 'restart', 'maintenance']
|
||||||
]
|
]:
|
||||||
|
telegram_bot.allow_during_maintenance(exception)
|
||||||
|
|
||||||
|
# Tasks to complete before starting bot
|
||||||
@telegram_bot.additional_task(when='BEFORE')
|
@telegram_bot.additional_task(when='BEFORE')
|
||||||
async def load_talking_sessions():
|
async def load_talking_sessions():
|
||||||
return await _load_talking_sessions(bot=telegram_bot)
|
return await _load_talking_sessions(bot=telegram_bot)
|
||||||
|
|
||||||
@telegram_bot.command(command='/talk',
|
@telegram_bot.additional_task(when='BEFORE', bot=telegram_bot)
|
||||||
|
async def notify_version(bot):
|
||||||
|
return await notify_new_version(bot=bot)
|
||||||
|
|
||||||
|
@telegram_bot.additional_task('BEFORE')
|
||||||
|
async def send_restart_messages():
|
||||||
|
return await _send_start_messages(bot=telegram_bot)
|
||||||
|
|
||||||
|
# Administration commands
|
||||||
|
@telegram_bot.command(command='/db',
|
||||||
aliases=[],
|
aliases=[],
|
||||||
show_in_keyboard=False,
|
show_in_keyboard=False,
|
||||||
description=admin_messages[
|
description=admin_messages[
|
||||||
'talk_command']['description'],
|
'db_command']['description'],
|
||||||
authorization_level='admin')
|
authorization_level='admin')
|
||||||
async def talk_command(bot, update, user_record):
|
async def send_bot_database(bot, update, user_record):
|
||||||
return await _talk_command(bot, update, user_record)
|
return await _send_bot_database(bot, update, user_record)
|
||||||
|
|
||||||
@telegram_bot.button(prefix='talk:///',
|
@telegram_bot.command(command='/errors',
|
||||||
|
aliases=[],
|
||||||
|
show_in_keyboard=False,
|
||||||
|
description=admin_messages[
|
||||||
|
'errors_command']['description'],
|
||||||
|
authorization_level='admin')
|
||||||
|
async def errors_command(bot, update, user_record):
|
||||||
|
return await _errors_command(bot, update, user_record)
|
||||||
|
|
||||||
|
@telegram_bot.command(command='/log',
|
||||||
|
aliases=[],
|
||||||
|
show_in_keyboard=False,
|
||||||
|
description=admin_messages[
|
||||||
|
'log_command']['description'],
|
||||||
|
authorization_level='admin')
|
||||||
|
async def log_command(bot, update, user_record):
|
||||||
|
return await _log_command(bot, update, user_record)
|
||||||
|
|
||||||
|
@telegram_bot.command(command='/maintenance', aliases=[],
|
||||||
|
show_in_keyboard=False,
|
||||||
|
description=admin_messages[
|
||||||
|
'maintenance_command']['description'],
|
||||||
|
authorization_level='admin')
|
||||||
|
async def maintenance_command(bot, update, user_record):
|
||||||
|
return await _maintenance_command(bot, update, user_record)
|
||||||
|
|
||||||
|
@telegram_bot.command(command='/query',
|
||||||
|
aliases=[],
|
||||||
|
show_in_keyboard=False,
|
||||||
|
description=admin_messages[
|
||||||
|
'query_command']['description'],
|
||||||
|
authorization_level='admin')
|
||||||
|
async def query_command(bot, update, user_record):
|
||||||
|
return await _query_command(bot, update, user_record)
|
||||||
|
|
||||||
|
@telegram_bot.button(prefix='db_query:///',
|
||||||
separator='|',
|
separator='|',
|
||||||
|
description=admin_messages[
|
||||||
|
'query_command']['description'],
|
||||||
authorization_level='admin')
|
authorization_level='admin')
|
||||||
async def talk_button(bot, update, user_record, data):
|
async def query_button(bot, update, user_record, data):
|
||||||
return await _talk_button(bot, update, user_record, data)
|
return await _query_button(bot, update, user_record, data)
|
||||||
|
|
||||||
@telegram_bot.command(command='/restart',
|
@telegram_bot.command(command='/restart',
|
||||||
aliases=[],
|
aliases=[],
|
||||||
@@ -1093,9 +1140,14 @@ def init(telegram_bot: Bot,
|
|||||||
async def restart_command(bot, update, user_record):
|
async def restart_command(bot, update, user_record):
|
||||||
return await _restart_command(bot, update, user_record)
|
return await _restart_command(bot, update, user_record)
|
||||||
|
|
||||||
@telegram_bot.additional_task('BEFORE')
|
@telegram_bot.command(command='/select',
|
||||||
async def send_restart_messages():
|
aliases=[],
|
||||||
return await _send_start_messages(bot=telegram_bot)
|
show_in_keyboard=False,
|
||||||
|
description=admin_messages[
|
||||||
|
'select_command']['description'],
|
||||||
|
authorization_level='admin')
|
||||||
|
async def select_command(bot, update, user_record):
|
||||||
|
return await _query_command(bot, update, user_record)
|
||||||
|
|
||||||
@telegram_bot.command(command='/stop',
|
@telegram_bot.command(command='/stop',
|
||||||
aliases=[],
|
aliases=[],
|
||||||
@@ -1114,69 +1166,20 @@ def init(telegram_bot: Bot,
|
|||||||
async def stop_button(bot, update, user_record, data):
|
async def stop_button(bot, update, user_record, data):
|
||||||
return await _stop_button(bot, update, user_record, data)
|
return await _stop_button(bot, update, user_record, data)
|
||||||
|
|
||||||
@telegram_bot.command(command='/db',
|
@telegram_bot.command(command='/talk',
|
||||||
aliases=[],
|
aliases=[],
|
||||||
show_in_keyboard=False,
|
show_in_keyboard=False,
|
||||||
description=admin_messages[
|
description=admin_messages[
|
||||||
'db_command']['description'],
|
'talk_command']['description'],
|
||||||
authorization_level='admin')
|
authorization_level='admin')
|
||||||
async def send_bot_database(bot, update, user_record):
|
async def talk_command(bot, update, user_record):
|
||||||
return await _send_bot_database(bot, update, user_record)
|
return await _talk_command(bot, update, user_record)
|
||||||
|
|
||||||
@telegram_bot.command(command='/query',
|
@telegram_bot.button(prefix='talk:///',
|
||||||
aliases=[],
|
|
||||||
show_in_keyboard=False,
|
|
||||||
description=admin_messages[
|
|
||||||
'query_command']['description'],
|
|
||||||
authorization_level='admin')
|
|
||||||
async def query_command(bot, update, user_record):
|
|
||||||
return await _query_command(bot, update, user_record)
|
|
||||||
|
|
||||||
@telegram_bot.command(command='/select',
|
|
||||||
aliases=[],
|
|
||||||
show_in_keyboard=False,
|
|
||||||
description=admin_messages[
|
|
||||||
'select_command']['description'],
|
|
||||||
authorization_level='admin')
|
|
||||||
async def select_command(bot, update, user_record):
|
|
||||||
return await _query_command(bot, update, user_record)
|
|
||||||
|
|
||||||
@telegram_bot.button(prefix='db_query:///',
|
|
||||||
separator='|',
|
separator='|',
|
||||||
description=admin_messages[
|
|
||||||
'query_command']['description'],
|
|
||||||
authorization_level='admin')
|
authorization_level='admin')
|
||||||
async def query_button(bot, update, user_record, data):
|
async def talk_button(bot, update, user_record, data):
|
||||||
return await _query_button(bot, update, user_record, data)
|
return await _talk_button(bot, update, user_record, data)
|
||||||
|
|
||||||
@telegram_bot.command(command='/log',
|
|
||||||
aliases=[],
|
|
||||||
show_in_keyboard=False,
|
|
||||||
description=admin_messages[
|
|
||||||
'log_command']['description'],
|
|
||||||
authorization_level='admin')
|
|
||||||
async def log_command(bot, update, user_record):
|
|
||||||
return await _log_command(bot, update, user_record)
|
|
||||||
|
|
||||||
@telegram_bot.command(command='/errors',
|
|
||||||
aliases=[],
|
|
||||||
show_in_keyboard=False,
|
|
||||||
description=admin_messages[
|
|
||||||
'errors_command']['description'],
|
|
||||||
authorization_level='admin')
|
|
||||||
async def errors_command(bot, update, user_record):
|
|
||||||
return await _errors_command(bot, update, user_record)
|
|
||||||
|
|
||||||
for exception in allowed_during_maintenance:
|
|
||||||
telegram_bot.allow_during_maintenance(exception)
|
|
||||||
|
|
||||||
@telegram_bot.command(command='/maintenance', aliases=[],
|
|
||||||
show_in_keyboard=False,
|
|
||||||
description=admin_messages[
|
|
||||||
'maintenance_command']['description'],
|
|
||||||
authorization_level='admin')
|
|
||||||
async def maintenance_command(bot, update, user_record):
|
|
||||||
return await _maintenance_command(bot, update, user_record)
|
|
||||||
|
|
||||||
@telegram_bot.command(command='/version',
|
@telegram_bot.command(command='/version',
|
||||||
aliases=[],
|
aliases=[],
|
||||||
@@ -1191,7 +1194,3 @@ def init(telegram_bot: Bot,
|
|||||||
return await _version_command(bot=bot,
|
return await _version_command(bot=bot,
|
||||||
update=update,
|
update=update,
|
||||||
user_record=user_record)
|
user_record=user_record)
|
||||||
|
|
||||||
@telegram_bot.additional_task(when='BEFORE', bot=telegram_bot)
|
|
||||||
async def notify_version(bot):
|
|
||||||
return await notify_new_version(bot=bot)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user