import traceback

import telegram
from telegram import chataction
from telegram.ext.dispatcher import run_async

from mayday import LogConfig
from mayday.constants import conversations, stages
from mayday.constants.replykeyboards import ReplyKeyboards
from mayday.features import search
from mayday.helpers.quick_search_helper import QuickSearchHelper
from mayday.utils import log_util

quick_search_helper = QuickSearchHelper('quick_search')
KEYBOARDS = ReplyKeyboards()
flogger = LogConfig.flogger


@run_async
def start(bot, update, user_data):
    try:
        telegram_info = update._effective_user
        callback_data = update.callback_query.data
        ticket = quick_search_helper.init_cache(
            user_id=telegram_info.id, username=telegram_info.username)

        msg = log_util.get_ub_log(user_id=telegram_info.id,
                                  username=telegram_info.username,
                                  funcname=__name__,
                                  callback_data=callback_data)
        flogger.info(msg)
예제 #2
0
from telegram.ext import (CallbackQueryHandler, CommandHandler,
                          ConversationHandler, Filters, MessageHandler,
                          RegexHandler, Updater)

import mayday
from mayday import AppConfig, LogConfig
from mayday.constants import stages
from mayday.constants.replykeyboards import ReplyKeyboards
from mayday.features import (mainpanel, post_ticket, search, support,
                             update_ticket, quick_search, platform_stats)

logger = LogConfig.flogger
keyboards = ReplyKeyboards()
token = AppConfig.token


def main():
    updater = Updater(token,
                      workers=64,
                      request_kwargs={
                          'read_timeout': 30,
                          'connect_timeout': 60
                      })
    dp = updater.dispatcher

    # Main Panel Handler
    main_panel_handler = ConversationHandler(
        entry_points=[
            CommandHandler('start',
                           mainpanel.start,
                           pass_user_data=True,