Ejemplo n.º 1
0
def callback_select_user_for_message_log_request(call):

    if call.message:
        num = re.search(r'^user(\d*)$', call.data)
        _id = num.group(1)
        u = db.get_user_by_id_namedtuple(_id)
        if u.message_log == config.REPLY[
                'communic_closed']:  # переписать условие
            keyboard = util.get_keyboard(
                (('Архив сообщений по последней коммуникаций пользователя',
                  'last_communic_log' + _id),
                 ('Архив сообщений по предыдущим коммуникациям пользователя',
                  'full_log' + _id)))
            bot.send_message(
                call.message.chat.id,
                '[ServiceBot] История сообщений по пользователю ' +
                u.first_name + ' ' + u.last_name + ', ' + 'Email: ' +
                u.email_address)
            util.send_history(call.message.chat.id,
                              u.message_log,
                              reply_markup=keyboard)
        else:
            keyboard = util.get_keyboard(
                (('Архив сообщений по предыдущим коммуникациям пользователя',
                  'full_log' + _id), ))
            bot.send_message(
                call.message.chat.id,
                '[ServiceBot] История сообщений по активной коммуникации пользователя '
                + u.first_name + ' ' + u.last_name + ', ' + 'Email: ' +
                u.email_address)
            util.send_history(call.message.chat.id,
                              u.message_log,
                              reply_markup=keyboard)
Ejemplo n.º 2
0
def callback_await_communic(call):

    if call.message:
        pre = util.get_prefix_for_servicebutton_reply(call.data)
        await_communics = db.get_awaiting_communics_namedtuple()
        if await_communics:
            bot.send_message(call.message.chat.id,
                             pre + '[ServiceBot] Список коммуникаций:')
            for c in await_communics:
                text = str(
                    c.id
                ) + '.) ' + 'Username: '******' ' + c.last_name + ', ' + 'Email: ' + c.email_address
                button = [[
                    'Перевести на себя коммуникацию с ' + c.first_name + ' ' +
                    c.last_name, 'take_open_communic' + c.chat_id
                ]]
                keyboard = util.get_keyboard(button)
                bot.send_message(call.message.chat.id,
                                 text,
                                 reply_markup=keyboard)
        else:
            bot.answer_callback_query(
                call.id,
                pre + '[ServiceBot] Нет ожидающих перевода коммуникаций.',
                show_alert=True)
Ejemplo n.º 3
0
def callback_return_current_communic(call):

    if call.message:
        pre = util.get_prefix_for_servicebutton_reply(call.data)
        u_chat_id = db.get_user_chat_id_by_responsible(call.from_user.id)
        if u_chat_id:
            u = db.get_user_namedtuple(u_chat_id)
            ui = util.print_userinfo(u_chat_id)
            db.append_message_to_history(
                u_chat_id, '[ServiceBot]: Специалист ' +
                util.get_support_name_by_chat_id(call.from_user.id) +
                ' перевел коммуникацию в незакрепленное состояние.')
            db.set_user(u_chat_id,
                        current_communic_is_appointed=0,
                        current_communic_responsible=0,
                        last_msg_time_from_user=int(time()))
            message_to_specialist = 'Вы перевели коммуникацию с пользователем\n\n' + ui + '\nв незакрепленное состояние.'
            message_to_group = '[ServiceBot] Специалист ' + util.get_support_name_by_chat_id(call.from_user.id) +\
                               ' перевел активную коммуникацию с пользователем\n\n' + ui + '\nв незакрепленное состояние.\n\nВы можете перевести на себя коммуникацию, нажав кнопку, следующую за данным сообщением.'
            bot.send_message(call.from_user.id, pre + message_to_specialist)
            button = [[
                'Перевести на себя коммуникацию с ' + u.first_name + ' ' +
                u.last_name, 'take_open_communic' + u.chat_id
            ]]
            keyboard = util.get_keyboard(button)
            for gr in SUPPORTGROUPS:
                bot.send_message(gr, message_to_group, reply_markup=keyboard)
        elif u_chat_id == None:
            bot.answer_callback_query(call.id,
                                      pre +
                                      config.REPLY['no_active_communics'],
                                      show_alert=True)
Ejemplo n.º 4
0
def message_first_message_of_new_communic(message):

    if message.text:
        db.append_message_to_history(message.chat.id, message.text)
    elif message.photo or message.document:
        util.process_content(message)
    db.set_user(message.chat.id,
                has_active_communics=1,
                last_msg_time_from_user=int(time()))
    template = config.REPLY['new_communication'].format(
        util.print_userinfo(message.chat.id, with_log=False))
    user = db.get_user_namedtuple(message.chat.id)
    button2 = [[
        'Перевести на себя коммуникацию с ' + user.first_name + ' ' +
        user.last_name, 'take_open_communic' + user.chat_id
    ]]
    keyboard = util.get_keyboard(button2)
    for gr in SUPPORTGROUPS:
        if message.text:
            util.send_history(gr, template, reply_markup=keyboard)
        elif message.photo:
            util.send_history(gr, template, reply_markup=keyboard)
            bot.send_message(gr,
                             '[ServiceBot]: Отправленное пользователем фото:')
            bot.send_photo(gr, util.get_file_photo_id(message))
        elif message.document:
            util.send_history(gr, template, reply_markup=keyboard)
            bot.send_message(gr,
                             '[ServiceBot]: Отправленный пользователем файл:')
            bot.send_document(gr, message.document.file_id)
Ejemplo n.º 5
0
def callback_message_log(call):

    if call.message:
        pre = util.get_prefix_for_servicebutton_reply(call.data)
        users = db.get_all_users_namedtuple()
        buttons = []
        for u in users:
            text = str(
                u.id
            ) + '.) ' + 'Username: '******' ' + u.last_name + ', ' + 'Email: ' + u.email_address
            buttons.append([text, 'user' + str(u.id)])
        keyboard = util.get_keyboard(buttons)
        bot.send_message(call.message.chat.id,
                         pre + '[ServiceBot] Выберите пользователя:',
                         reply_markup=keyboard)
Ejemplo n.º 6
0
def kb_for_controllers(message):

    keyboard = util.get_keyboard(config.CONTROLLERS_KEYBOARD)
    bot.send_message(message.chat.id,
                     '[ServiceBot] Сервисное меню:',
                     reply_markup=keyboard)
Ejemplo n.º 7
0
def kb_for_supports(message):

    keyboard = util.get_keyboard(config.SUPPORTS_KEYBOARD)
    bot.send_message(message.chat.id,
                     '[ServiceBot] Сервисное меню:',
                     reply_markup=keyboard)
Ejemplo n.º 8
0
def kb_for_users(message):

    keyboard = util.get_keyboard(config.USERS_KEYBOARD)
    bot.send_message(message.chat.id, 'Сервисное меню:', reply_markup=keyboard)