当前位置: 首页>>代码示例>>Python>>正文


Python ConversationHandler.END属性代码示例

本文整理汇总了Python中telegram.ext.ConversationHandler.END属性的典型用法代码示例。如果您正苦于以下问题:Python ConversationHandler.END属性的具体用法?Python ConversationHandler.END怎么用?Python ConversationHandler.END使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在telegram.ext.ConversationHandler的用法示例。


在下文中一共展示了ConversationHandler.END属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: polo

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def polo(self, bot, update, user_data):
        msg = update.message.text.upper()
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        c.execute("SELECT name FROM handles WHERE name=(?)", (msg,))
        if c.fetchone():
            keyboard = [[InlineKeyboardButton("Hackerearth", callback_data='HElist8'),
                         InlineKeyboardButton("Hackerrank", callback_data='HRlist8')],
                        [InlineKeyboardButton("Codechef", callback_data='CClist8'),
                         InlineKeyboardButton("Spoj", callback_data='SPlist8')],
                        [InlineKeyboardButton("Codeforces", callback_data='CFlist8'),
                         InlineKeyboardButton("ALL", callback_data='ALLlist8')]]
            reply_markup = InlineKeyboardMarkup(keyboard)
            update.message.reply_text('please select the judge or select all for showing all',
                                      reply_markup=reply_markup)
            user_data['name1'] = msg
            conn.close()
            return XOLO
        else:
            conn.close()
            update.message.reply_text("Sorry this name is not registered with me.")
            return ConversationHandler.END

    # FUNCTION TO SHOW THE KIND OF RANKLIST USER WANTS 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:26,代码来源:ranklist.py

示例2: code

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def code(bot, update, user_data):
        query = update.callback_query
        val = query.data
        val = str(val).replace("so1", "")
        if val == "code":
            bot.edit_message_text(
                text="selected",
                chat_id=query.message.chat_id, message_id=query.message.message_id)
            bot.send_message(chat_id=query.message.chat_id, text="please enter your code\n"
                                                                  "Please make sure that "
                                                                  "the first line is not a comment line",
                             reply_markup=ForceReply(True))
            return DECODE
        elif val == "file":
            bot.edit_message_text(text="please send your .txt file\nMaximum size 2mb", chat_id=query.message.chat_id,
                                  message_id=query.message.message_id)
            return FILE
        else:
            return ConversationHandler.END

    # FUNCTION TO GET TESTCASE FILE 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:23,代码来源:compiler.py

示例3: filetest

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def filetest(self, bot, update, user_data):
        file_id = update.message.document.file_id
        if ComHandler.check_file_size(update):
            return ConversationHandler.END
        newFile = bot.get_file(file_id)
        newFile.download('test.txt')
        with open('test.txt', 'rt') as f:
            source = f.read()
        s1 = (str(user_data['code'])).replace("«", "<<").replace("»", ">>")
        result = self.compiler.run({'source': s1,
                               'lang': user_data['lang'],
                               'testcases': [source]
                               })
        Utility.paginate(bot, update, result)
        user_data.clear()
        os.remove('test.txt')
        return ConversationHandler.END 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:19,代码来源:compiler.py

示例4: filer

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def filer(bot, update, user_data):
        file_id = update.message.document.file_id
        if ComHandler.check_file_size(update):
            return ConversationHandler.END
        newFile = bot.get_file(file_id)
        newFile.download('abcd.txt')
        with open('abcd.txt', 'r') as f:
            source = f.read()
        user_data['code'] = source
        custom_keyboard = [['#no test case', '#send a .txt file']]
        reply_markup = ReplyKeyboardMarkup(custom_keyboard, one_time_keyboard=True, resize_keybord=True)
        update.message.reply_text(
            'Please send test cases together as you would do in online ide\nIf you dont want to provide test cases select #no test case\n I you want to send test cases as .txt file select #send a .txt file',
            reply_markup=reply_markup)
        # REMOVING THE FILE AFTER PROCESS IS COMPLETE
        os.remove('abcd.txt')
        return TESTCASES

    # FUNCTION TO GET THE SOURCE CODE SENT BY USER 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:21,代码来源:compiler.py

示例5: qselcf

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def qselcf(self, bot, update):
        query = update.callback_query
        val = query.data
        if val == 'Acf1':
            strn = self.get_random_ques('A')
        elif val == 'Bcf1':
            strn = self.get_random_ques('B')
        elif val == 'Ccf1':
            strn = self.get_random_ques('C')
        elif val == 'Dcf1':
            strn = self.get_random_ques('D')
        elif val == 'Ecf1':
            strn = self.get_random_ques('E')
        elif val == 'Fcf1':
            strn = self.get_random_ques('F')
        elif val == 'OTHERScf1':
            strn = self.get_random_ques('OTHERS')
        val = str(val).replace("cf1", "")
        bot.edit_message_text(
            text="Random " + val + " question from codeforces\n\n" + strn,
            chat_id=query.message.chat_id,
            message_id=query.message.message_id)
        return ConversationHandler.END
        # END OF CONVERSATION HANDLER FOR GETTING RANDOM QUESTION FROM CODEFORCES 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:26,代码来源:codeforces.py

示例6: broadcast_message

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def broadcast_message(self, bot, update):
        message = update.message.text
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        c.execute('select id from handles union select id from subscribers')
        for row in c.fetchall():
            try:
                bot.send_message(text=message, chat_id=row[0])
            except:
                pass
            time.sleep(1)
        c.close()
        conn.close()
        return ConversationHandler.END

    # END OF ADMIN CONVERSATION HANDLER TO BROADCAST MESSAGE

    # START OF ADMIN CONVERSATION HANDLER TO REPLACE THE DATABASE 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:20,代码来源:admin.py

示例7: register

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def register(self, bot,update):
		try:
			with closing(self.conn.cursor()) as cur:
				uid = update.message.from_user.id
				cur.execute("""SELECT telegram_id FROM User WHERE telegram_id = %s""",(uid,))
				if cur.rowcount == 0:
					message = "Registering you in my database! \n"
					message += "Can I please have the generation index?\n"
					message += "This bot will search for the generation index less than or equals to the number you input\n"
					message += "If you feel threatened at any point of time, do a /cancel to abort this conversation."
					cur.execute("""INSERT INTO User VALUES(%s,NULL,NULL,NULL,NULL,'No')""",(uid,))
					update.message.reply_text(message,parse_mode='HTML')
					return GENERATION
				else:
					message = "You are already registered in my database. To remove your details, do a /forget"
					update.message.reply_text(message,parse_mode='HTML')
					return ConversationHandler.END


		except Exception as e:
			catcherror = traceback.format_exc()
			bot.sendMessage(chat_id=Tokens().error_channel(),text=catcherror,parse_mode='HTML') 
开发者ID:xlanor,项目名称:CryptoKitties,代码行数:24,代码来源:commands.py

示例8: attribute_list

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def attribute_list(self,bot,update):
		try:
			with closing(self.conn.cursor()) as cur:
				uid = update.message.from_user.id
				if str.lower(update.message.text) == "end":
					message = "Thanks for registering =)\n"
					message = "If you want to toggle 10 minute scans, please do a /alert"
					update.message.reply_text(message,parse_mode='HTML')
					return ConversationHandler.END
				else:
					cur.execute("""INSERT INTO Attribute VALUES(%s,%s)""",(uid,update.message.text,))
					message= update.message.text
					message += " has been added as an attribute. Please enter the next attribute \n"
					message += "If you're done with adding your cattributes, please reply with end"
					update.message.reply_text(message,parse_mode='HTML')
					return ATTLIST

		except Exception as e:
			catcherror = traceback.format_exc()
			bot.sendMessage(chat_id=Tokens().error_channel(),text=catcherror,parse_mode='HTML') 
开发者ID:xlanor,项目名称:CryptoKitties,代码行数:22,代码来源:commands.py

示例9: send_broadcast

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def send_broadcast(bot, update, user_data):
    uid = update.effective_user.id

    try:
        bc = user_data['broadcast']
        text = bc['text']
        recipient = bc['target_chat_id']
        mode = bc.get('mode', 'just_send')
    except AttributeError:
        bot.formatter.send_failure(uid, "Missing attributes for broadcast. Aborting...")
        return ConversationHandler.END

    mid = bc.get('reply_to_message_id')

    if mode == 'replying':
        msg = util.send_md_message(bot, recipient, text, reply_to_message_id=mid)
    elif mode == 'editing':
        msg = bot.formatter.send_or_edit(recipient, text, to_edit=mid)
    else:
        msg = util.send_md_message(bot, recipient, text)

    # Post actions
    buttons = [
        InlineKeyboardButton(captions.PIN,
                             callback_data=util.callback_for_action('pin_message', {'mid': msg.message_id})),
        InlineKeyboardButton('Add "Thank You" counter',
                             callback_data=util.callback_for_action('add_thank_you',
                                                                    {'cid': recipient, 'mid': msg.message_id})),
    ]
    reply_markup = InlineKeyboardMarkup(util.build_menu(buttons, 1))
    mid = util.mid_from_update(update)
    action_taken = "edited" if mode == 'editing' else "broadcasted"
    bot.formatter.send_or_edit(uid, mdformat.success("Message {}.".format(action_taken)), mid, reply_markup=reply_markup) 
开发者ID:JosXa,项目名称:BotListBot,代码行数:35,代码来源:broadcasts.py

示例10: cancel

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def cancel(bot, update, user_data):
        update.message.reply_text('Cancelled')
        user_data.clear()
        return ConversationHandler.END

    # FUNCTION FOR LOGGING ALL KINDS OF ERRORS 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:8,代码来源:app.py

示例11: getCf

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def getCf(self, bot, update):
        if not str(update.message.chat_id) in self.admin_list:
            update.message.reply_text("sorry you are not an admin")
            return ConversationHandler.END
        update.message.reply_text("send your json file")
        return self.CF 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:8,代码来源:app.py

示例12: receive_cf

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def receive_cf(self, bot, update):
        file_id = update.message.document.file_id
        newFile = bot.get_file(file_id)
        newFile.download(self.mount_point + 'codeforces.json')
        update.message.reply_text("saved")
        with open(self.mount_point + 'codeforces.json', 'r') as code_json:
            self.cf.change_cf(json.load(code_json))
        return ConversationHandler.END

    # END OF ADMIN CONVERSATION HANDLER TO REPLACE THE CODEFORCES JSON 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:12,代码来源:app.py

示例13: testcases

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def testcases(self, bot, update, user_data):
        markup = ReplyKeyboardRemove()
        s = update.message.text
        if s == "#send a .txt file":
            update.message.reply_text("Please send your testcases as a .txt file\nMaximum size 2mb",
                                      reply_markup=markup)
            return FILETEST
            # CONVERTING UNICODE CHARACTER TO DOUBLE GREATER THAN OR LESS THAN
            # WEIRD
        s1 = (str(user_data['code'])).replace("«", "<<").replace("»", ">>")
        if s == "#no test case":
            # USING COMPILER FUNCTION FROM helper.py script
            result = self.compiler.run({'source': s1,
                                   'lang': user_data['lang']
                                   })
            # GETTING OUTPUT FROM result CLASS in helper.py script
            Utility.paginate(bot, update, result)
        else:
            # AGAIN THE SAME DRILL
            result = self.compiler.run({'source': s1,
                                   'lang': user_data['lang'],
                                   'testcases': [s]
                                   })
            Utility.paginate(bot, update, result)
        user_data.clear()
        return ConversationHandler.END

    # FUNCTION FOR THE CASE WHERE USER HAD SELECTED OTHER 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:30,代码来源:compiler.py

示例14: solo

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def solo(self, bot, update):
        query = update.callback_query
        val = query.data
        choices = ['HElist7', 'HRlist7', 'CClist7', 'SPlist7', 'CFlist7', 'ALLlist7']
        if val not in choices:
            return ConversationHandler.END
        val = str(val).replace("list7", "")
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        if val == "ALL":
            a = str(query.from_user.id)
            bot.edit_message_text(text='Sending please wait',
                                  chat_id=query.message.chat_id,
                                  message_id=query.message.message_id)
            mysel = c.execute("SELECT name, HE, HR, SP, CC, CF FROM datas WHERE id=" + a)
            self.utility.xlsx_creator(mysel, 'me.xlsx')
            bot.send_document(chat_id=query.message.chat_id, document=open('me.xlsx', 'rb'))
            os.remove('me.xlsx')
        else:
            a = str(query.from_user.id)
            c.execute("SELECT " + val + " FROM datas WHERE id=" + a)
            for i in c.fetchall():
                if i[0] is None or i[0] == "":
                    bot.edit_message_text(text="NOT REGISTERED",
                                          chat_id=query.message.chat_id,
                                          message_id=query.message.message_id)
                else:
                    bot.edit_message_text(text="" + i[0],
                                          chat_id=query.message.chat_id,
                                          message_id=query.message.message_id)
        conn.commit()
        conn.close()
        return ConversationHandler.END

    # FUNCTION TO GET THE RANKLIST MENU OF THE USER BY SEARCHING HIS NAME 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:37,代码来源:ranklist.py

示例15: xolo

# 需要导入模块: from telegram.ext import ConversationHandler [as 别名]
# 或者: from telegram.ext.ConversationHandler import END [as 别名]
def xolo(self, bot, update, user_data):
        query = update.callback_query
        val = query.data
        choices = ['HElist8', 'HRlist8', 'CClist8', 'SPlist8', 'CFlist8', 'ALLlist8']
        if val not in choices:
            return ConversationHandler.END
        val = str(val).replace("list8", "")
        name1 = user_data['name1']
        conn = sqlite3.connect(self.mount_point + 'coders1.db')
        c = conn.cursor()
        if val == "ALL":
            bot.edit_message_text(text='Sending please wait',
                                  chat_id=query.message.chat_id,
                                  message_id=query.message.message_id)
            mysel = c.execute("SELECT name, HE, HR, SP, CC, CF FROM datas WHERE name=(?)", (name1,))
            self.utility.xlsx_creator(mysel, 'det.xlsx')
            bot.send_document(chat_id=query.message.chat_id, document=open('det.xlsx', 'rb'))
            os.remove('det.xlsx')
        else:
            c.execute("SELECT " + val + " FROM datas WHERE name=(?)", (name1,))
            for i in c.fetchall():
                if i[0] is None or i[0] == "":
                    bot.edit_message_text(text="Not Registered",
                                          chat_id=query.message.chat_id,
                                          message_id=query.message.message_id)
                else:
                    bot.edit_message_text(text="" + i[0],
                                          chat_id=query.message.chat_id,
                                          message_id=query.message.message_id)
        user_data.clear()
        conn.close()
        return ConversationHandler.END

    # FUNCTION TO SHOW THE RANKLIST OF ALL THE PEOPLE 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:36,代码来源:ranklist.py


注:本文中的telegram.ext.ConversationHandler.END属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。