Пример #1
0
def company(update, _):
    #update.message.reply_text(update.message.text)
    #message_text = update.message.text
    chat_id = update.message.chat_id
    user_id = update.message.chat.id
    uid = str(user_id)

    nickname = update.message.from_user.username

    user = User(nickname, uid)

    reg = backend.search(user.userid)
    if reg:
        send_new_problem(user_id, chat_id)
        return

    if not user.register(bot, chat_id, update):
        reply = 'Unable to create an account!'
        bot.send_message(chat_id=chat_id, text=reply)
        return

    logger.info(f'User {nickname}({uid}) registered')
    ENTITY[uid] = user
    bot.send_message(chat_id=chat_id, text=reply_msg('welcome'))
    send_new_problem(user_id, chat_id)
Пример #2
0
def start_handler(update, _):
    global ENTITY
    chat_id = update.message.chat_id
    uid = str(chat_id)
    nickname = update.message.from_user.first_name

    if uid in ENTITY:
        send_new_problem(chat_id)
    else:
        user = User(uid, nickname)
        if not user.register():
            reply = '無法建立帳號,請於粉專或 discord 私訊小編!'
            bot.send_message(chat_id=chat_id, text=reply)
            return

        logger.info(f'User {nickname}({uid}) registered')
        ENTITY[uid] = user
        bot.send_message(chat_id=chat_id, text=reply_msg('welcome'))
        send_new_problem(chat_id)