Пример #1
0
def command_notify_all_test(message):
    user_action_log(message, 'called ' + message.text)
    split = message.text.split(' ', 1)
    if len(split) > 1:
        subs_notify([message.from_user.id],
                    '{}\n\n{}'.format(bold('Оповещение пользователей бота'),
                                      split[1]))
Пример #2
0
def update_bot(message):
    if not hasattr(update_bot, 'check_sure'):
        update_bot.check_sure = True
        return

    my_bot.reply_to(message, 'Ух, ухожу на обновление...')
    user_action_log(message, 'remotely ran update script.')
    os.execl('/bin/bash', 'bash', 'utils/__bot_update.sh')
Пример #3
0
 def wrapped(message):
     if not self.is_registered(message) or not self.is_name_set(
             message):
         user_action_log(message,
                         'not registered to call: ' + message.text)
         self.register_user(message)
         return
     return func(message)
Пример #4
0
 def wrapped(call):
     if not self.is_registered(call) or not self.is_name_set(call):
         user_action_log(call,
                         'not registered to callback: ' + call.data)
         my_bot.answer_callback_query(callback_query_id=call.id,
                                      show_alert=False,
                                      text='⛔️ Нет доступа')
         return
     return func(call)
Пример #5
0
def kill_bot(message):
    if not hasattr(kill_bot, 'check_sure'):
        kill_bot.check_sure = True
        return
    value_to_file(config.FileLocation.bot_killed, 1)
    my_bot.send_document(message.chat.id,
                         'https://t.me/mechmath/169445',
                         caption='Ухожу на отдых!',
                         reply_to_message_id=message.message_id)
    user_action_log(message, 'remotely killed bot.')
    sys.exit(0)
Пример #6
0
def command_notify_all(message):
    user_action_log(message, 'called ' + message.text)
    split = message.text.split(' ', 1)
    if len(split) > 1:
        subs_notify(my_data.list_users(),
                    '{}\n\n{}'.format(bold('Оповещение пользователей бота'),
                                      split[1]),
                    me=message.from_user.id)

    else:
        my_bot.reply_to(message, 'Использование: /notify_all [ваше сообщение]')
Пример #7
0
def command_day(message):
    user_action_log(message, 'called ' + message.text)
    split = message.text.split(' ', 1)
    if len(split) > 1:
        subs_notify(
            config.admin_ids, 'Обратная связь от {}: {}'
            ''.format(
                link(my_data.data[str(message.from_user.id)]['who'],
                     message.from_user.id), split[1]))
        my_bot.reply_to(message, 'Сообщение отправлено!')
    else:
        my_bot.reply_to(message, 'Использование: /feedback [ваше обращение]')
Пример #8
0
def command_help(message):
    user_action_log(message, 'called ' + message.text)
    with open(config.FileLocation.cmd_help, 'r', encoding='utf-8') as file:
        my_bot.reply_to(message,
                        file.read(),
                        parse_mode='HTML',
                        disable_web_page_preview=True)
    if message.from_user.id in config.admin_ids:
        with open(config.FileLocation.cmd_help_admin, 'r',
                  encoding='utf-8') as file:
            my_bot.reply_to(message,
                            file.read(),
                            parse_mode='HTML',
                            disable_web_page_preview=True)
Пример #9
0
def command_start(message):
    user_action_log(message, 'called ' + message.text)
    split = message.text.split()
    if len(split) == 1:
        if not my_data.is_registered(message):
            user_action_log(message, 'not registered to call: ' + message.text)
            my_data.register_user(message)
            return
        with open(config.FileLocation.cmd_start, 'r',
                  encoding='utf-8') as file:
            my_bot.reply_to(message,
                            file.read(),
                            parse_mode='HTML',
                            disable_web_page_preview=True)
    else:
        deep_link = split[1]
        if deep_link.startswith('donate'):
            donate.donate(message)
Пример #10
0
 def check_password(self, message):
     if tokens.access_pswd != '' and message.text == tokens.access_pswd:
         if self.data.get(str(message.from_user.id)) is None:
             self.data[str(message.from_user.id)] = {}
         self.data[str(message.from_user.id)]['authenticated'] = 'True'
         user_action_log(message, 'successfully registered')
         my_bot.reply_to(message, '✅ Пароль верный!')
         subs_notify(
             config.admin_ids, '✨ Новый пользователь: {}'.format(
                 link_user(message.from_user)))
         self.data[str(message.from_user.id)]['who'] = user_name(
             message.from_user)
         self.register_user(message)
     else:
         user_action_log(message, 'entered wrong password')
         my_bot.reply_to(
             message,
             '⛔ Пароль не подошел!\n\nВызывай /start для новой попытки.')
Пример #11
0
def command_reply(message):
    user_action_log(message, 'called ' + message.text)
    if hasattr(message, 'reply_to_message'):
        split = message.text.split(' ', 1)
        if len(split) > 1:
            replying_msg = message.reply_to_message
            if hasattr(replying_msg, 'entities'):
                user_ids = [
                    x.user.id for x in replying_msg.entities
                    if x.type == 'text_mention'
                ]
                if len(user_ids) == 1:
                    my_bot.send_message(user_ids[0],
                                        '{}: {}'.format(
                                            bold('Разработчик'), split[1]),
                                        parse_mode='HTML')
                    my_bot.reply_to(message, 'Сообщение отправлено!')
                    return
    my_bot.reply_to(message,
                    'Использовать с ответом на фидбек: /reply [ваш ответ]')
Пример #12
0
def command_restart(message):
    user_action_log(message, 'called ' + message.text)
    my_data.register_user(message)
Пример #13
0
def got_payment(message):
    user_action_log(message, 'payed money!')
    donate.got_payment(message)
Пример #14
0
def chai_chat(message):
    message.text = '/ch ' + message.text
    user_action_log(message, 'called ' + message.text)
    chai.chai_message(message)
Пример #15
0
def command_commands(message):
    user_action_log(message, 'called ' + message.text)
    stats.commands(message)
Пример #16
0
def callback_in_office(call):
    user_action_log(call, 'callbacked ' + call.data)
    if tokens.chatbase_token != '':
        my_analytics.track_callback(call)
    my_acs.in_office_update(call)
Пример #17
0
def command_in_office(message):
    user_action_log(message, 'called ' + message.text)
    my_acs.in_office_now(message)
Пример #18
0
def command_camera(message):
    user_action_log(message, 'called ' + message.text)
    playroom.camera_n_show(message)
Пример #19
0
def command_donate(message):
    user_action_log(message, 'called ' + message.text)
    donate.donate(message)
Пример #20
0
def callback_chai(call):
    user_action_log(call, 'callbacked ' + call.data)
    if tokens.chatbase_token != '':
        my_analytics.track_callback(call)
    chai.chai_callback(call)
Пример #21
0
def callback_settings(call):
    user_action_log(call, 'callbacked ' + call.data)
    if tokens.chatbase_token != '':
        my_analytics.track_callback(call)
    my_data.get_user_settings(call.from_user.id).settings_update(call)
    my_data.save()
Пример #22
0
def callback_camera(call):
    user_action_log(call, 'callbacked ' + call.data)
    if tokens.chatbase_token != '':
        my_analytics.track_callback(call)
    playroom.update_camera(call)
Пример #23
0
def command_date(message):
    user_action_log(message, 'called ' + message.text)
    my_acs.reply_time(message)
Пример #24
0
def command_settings(message):
    user_action_log(message, 'called ' + message.text)
    my_data.get_user_settings(
        message.from_user.id).show_settings_message(message)
Пример #25
0
def command_state(message):
    user_action_log(message, 'called ' + message.text)
    my_acs.user_state(message)
Пример #26
0
def command_log(message):
    user_action_log(message, 'called ' + message.text)
    with open(config.FileLocation.bot_logs, 'r', encoding='utf-8') as file:
        lines = file.readlines()[-100:]
        for text in cut_long_text(''.join(lines)):
            my_bot.reply_to(message, '{}'.format(text))
Пример #27
0
def command_vacation(message):
    user_action_log(message, 'called ' + message.text)
    vacation.on_vacation_now(message)
Пример #28
0
def command_dump(message):
    user_action_log(message, 'called ' + message.text)
    my_data.dump_file(message)
Пример #29
0
def command_touch_all(message):
    user_action_log(message, 'called ' + message.text)
    for chat_id in my_data.list_users():
        my_bot.send_chat_action(chat_id, action='typing')
Пример #30
0
def callback_time(call):
    user_action_log(call, 'callbacked ' + call.data)
    if tokens.chatbase_token != '':
        my_analytics.track_callback(call)
    my_acs.reply_time_update(call)