ChatUtils2.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:TelegramBots 作者: d-qoi 项目源码 文件源码
def registerMe(bot, update):
    if not checkValidCommand(update.message.text, bot.username):
        return

    if not checkTypeGroup(update):
        update.message.reply_text("This only works in groups the bot is in. If you would like to add the bot to a group, do so and then send /registerme")
        return

    #userDict = createUserDict(update.message.from_user)
    userDict = update.message.from_user.id
    logger.debug("New User: %s" % str(userDict))
    mDatabase.groups.update({'_id':update.message.chat.id},
                            {'$addToSet':{'users':userDict},
                             '$set':{'title':update.message.chat.title}},
                            upsert=True)

    logger.info("Register Me called for %s (%s)" % (update.message.chat.title, update.message.chat.id))
    keyboard = [[InlineKeyboardButton("Register Me!", 
                                      callback_data="RegisterMe")]]
    markup = InlineKeyboardMarkup(keyboard)
    reply_text = "If you would like to register with this bot for this group, send /registerme, or click the button below."
    try:
        bot.sendMessage(chat_id = update.message.chat.id,
                        text = reply_text,
                        reply_markup = markup)
    except TelegramError as TE:
        logger.error("Caught this from registerMe: %s" % str(TE))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号