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


Python Updates.get_updates方法代码示例

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


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

示例1: set_phpsessid

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def set_phpsessid(bot: telegram.Bot, update: telegram.Update):
    chat_id = update.message.chat_id
    user_id = update.message.from_user.id
    try:
        state = State(bot, chat_id, user_id, phpsessid_conversation,
                      phpsessid_done)
        state['command'] = update.message.text
        state['from'] = update.message.from_user.name
        message = 'stap 1: login op jotihunt.net\n ' \
                  'stap2: zoek uit hoe je cookies van jothunt.net uitleest in je browser. \n ' \
                  'stap 3: ga op zook naar de cookie met de naam PHPSESSID.\n  ' \
                  'stap 4: plak de waarde hier om de cookie te  verversen van de bot.\n' \
                  ' of /cancel om te stoppen'
        bot.sendMessage(chat_id, message,
                        reply_to_message_id=update.message.message_id)
    # TODO add a keyboard
        Updates.get_updates().botan.track(update.message, 'phpsessid')
    except MultipleConversationsError:
        bot.sendMessage(chat_id, "Er is al een commando actief je kunt dit "
                                 "commando niet starten.\n"
                                 " type /cancel om het vorige commando te "
                                 "stoppen te stoppeny",
                        reply_to_message_id=update.message.message_id)
        Updates.get_updates().botan.track(update.message,
                                          'incorrect_phpsessid')
开发者ID:RSDT,项目名称:bot2,代码行数:27,代码来源:commands.py

示例2: bug

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def bug(bot: telegram.Bot, update: telegram.Update):
    """

                :param bot:
                :param update:
                :return:
                """
    chat_id = update.message.chat_id
    user_id = update.message.from_user.id
    try:
        state = State(bot, chat_id, user_id, bug_conversation, bug_done)
        state['command'] = update.message.text
        state['from'] = update.message.from_user.name
        keyboard = telegram.ReplyKeyboardMarkup([['app'], ['site'],
                                                 ['anders']])
        bot.sendMessage(chat_id, "Waar wil je een tip of een top voor "
                                 "sturen?\napp/bot/site/anders",
                        reply_to_message_id=update.message.message_id,
                        reply_markup=keyboard)
        Updates.get_updates().botan.track(update.message, 'bug')
    except MultipleConversationsError:
        bot.sendMessage(chat_id, "Er is al een commando actief je kunt dit "
                                 "commando niet starten.\n"
                                 " type /cancel om het vorige commando te "
                                 "stoppen te stoppen",
                        reply_to_message_id=update.message.message_id)
        Updates.get_updates().botan.track(update.message, 'incorrect_bug')
开发者ID:RSDT,项目名称:bot2,代码行数:29,代码来源:commands.py

示例3: cancel

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def cancel(bot: telegram.Bot, update: telegram.Update):
    """

    :param bot:
    :param update:
    :return:
    """
    chat_id = update.message.chat_id
    user_id = update.message.from_user.id
    h = str(user_id) + str(chat_id)
    try:
        state = State.states[h]
        state.cancel()
    except KeyError:
        kb = telegram.ReplyKeyboardHide()
        if update.message.chat_id > 0:
            keyboard = DEFAULT_KEYBOARD
            kb = telegram.ReplyKeyboardMarkup(keyboard,
                                              one_time_keyboard=False,
                                              selective=True)
        bot.sendMessage(chat_id, "Er is geen commando actief.",
                        reply_to_message_id=update.message.message_id,
                        reply_markup=kb)
        Updates.get_updates().botan.track(update.message, 'incorrect_cancel')
    else:
        kb = telegram.ReplyKeyboardHide()
        if update.message.chat_id > 0:
            keyboard = DEFAULT_KEYBOARD
            kb = telegram.ReplyKeyboardMarkup(keyboard,
                                              one_time_keyboard=False,
                                              selective=True)
        bot.sendMessage(update.message.chat_id, "Het commando is gestopt.",
                        reply_to_message_id=update.message.message_id,
                        reply_markup=kb)
        Updates.get_updates().botan.track(update.message, 'cancel')
开发者ID:RSDT,项目名称:bot2,代码行数:37,代码来源:commands.py

示例4: help_command

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def help_command(bot: telegram.Bot, update: telegram.Update):
    message = start_message + "\n\n"
    for commando in CommandHandlerWithHelp.helps:
        message += '/' + commando + ' - ' + CommandHandlerWithHelp.helps[
            commando] + '\n'
    bot.sendMessage(update.message.chat_id, message)
    Updates.get_updates().botan.track(update.message, 'help')
开发者ID:RSDT,项目名称:bot2,代码行数:9,代码来源:commands.py

示例5: test

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def test(bot: telegram.Bot, update: telegram.Update):
    bot.sendMessage(update.message.chat_id, 'de bot is online')
    if update.message.chat_id > 0:
        url = Updates.get_updates().botan.shorten('http://google.com',
                                                  update.message.from_user.id)
    else:
        url = 'http://google.com'
    bot.sendMessage(update.message.chat_id, url)
    Updates.get_updates().botan.track(update.message, 'test')
开发者ID:RSDT,项目名称:bot2,代码行数:11,代码来源:commands.py

示例6: start

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def start(bot: telegram.Bot, update: telegram.Update):
    if update.message.chat_id > 0:
        keyboard = telegram.ReplyKeyboardMarkup(DEFAULT_KEYBOARD,
                                                one_time_keyboard=False)
        bot.sendMessage(update.message.chat_id, start_message,
                        reply_markup=keyboard)
    else:
        bot.sendMessage(update.message.chat_id, start_message)
    x = authenticate()
    x(lambda bot2, update2: print('authenticated:\n' + str(update.to_dict(
    ))))(bot, update)
    Updates.get_updates().botan.track(update.message, 'start')
开发者ID:RSDT,项目名称:bot2,代码行数:14,代码来源:commands.py

示例7: restart

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def restart(bot, update):
    api = RpApi.get_instance(settings.Settings().rp_username, settings.Settings().rp_pass)
    response = api.get_telegram_link(update.effective_user.id)
    rp_acc = response.data
    if rp_acc is None:
        bot.send_message(update.effective_chat.id, 'Je telegram account is nog niet gelinkt.'
                                                   ' vraag aan de homebase of ze dat willen doen.',
                         reply_to_message_id=update.effective_message.message_id)
        return
    if int(rp_acc['toegangslvl']) < 75 and int(update.effective_user.id) != 19594180:
        bot.send_message(update.effective_chat.id, 'Je bent niet gemachtigd om dit commando uit te voeren',
                         reply_to_message_id=update.effective_message.message_id)
        return
    bot.send_message(update.effective_chat.id, "bot gaat herstarten.")
    try:
        updates: Updates = Updates.get_updates()
        updates.to_all('de bot gaat herstarten')
        updates.exit()
        updates.save()
        with open(STARTUPFILE, 'wb') as file:
            pickle.dump({'command': 'restart'}, file)
        os.execl(sys.executable, sys.executable, *sys.argv)
    except Exception as e:
        print(e)
        raise e
开发者ID:RSDT,项目名称:bot2,代码行数:27,代码来源:menu.py

示例8: _updates_aan_uit_menu

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
 def _updates_aan_uit_menu(self, update: Update, callback_query: str, rp_acc)->Tuple[str, List[InlineKeyboardButton]]:
     updates = Updates.get_updates()
     message = ''
     zet_aan = callback_query == 'a'
     if zet_aan:
         message = 'updates voor ' + str(self.path[-2]) + ' zijn aangezet.'
     else:
         message = 'updates voor ' + str(self.path[-2]) + ' zijn uitgezet.'
     if self.path[-2] == 'A':
         updates.set_updates(update.effective_chat.id, Updates.ALPHA, zet_aan)
     elif self.path[-2] == 'B':
         updates.set_updates(update.effective_chat.id, Updates.BRAVO, zet_aan)
     elif self.path[-2] == 'C':
         updates.set_updates(update.effective_chat.id, Updates.CHARLIE, zet_aan)
     elif self.path[-2] == 'D':
         updates.set_updates(update.effective_chat.id, Updates.DELTA, zet_aan)
     elif self.path[-2] == 'E':
         updates.set_updates(update.effective_chat.id, Updates.ECHO, zet_aan)
     elif self.path[-2] == 'F':
         updates.set_updates(update.effective_chat.id, Updates.FOXTROT, zet_aan)
     elif self.path[-2] == 'X':
         updates.set_updates(update.effective_chat.id, Updates.XRAY, zet_aan)
     elif self.path[-2] == 'hints':
         updates.set_updates(update.effective_chat.id, Updates.HINTS, zet_aan)
     elif self.path[-2] == 'nieuws':
         updates.set_updates(update.effective_chat.id, Updates.NIEUWS, zet_aan)
     elif self.path[-2] == 'opdracht':
         updates.set_updates(update.effective_chat.id, Updates.OPDRACHTEN, zet_aan)
     elif self.path[-2] == 'error':
         updates.set_updates(update.effective_chat.id, Updates.ERROR, zet_aan)
     else:
         message = 'error, waarschijnlijk heb je meerdere knoppen in het zelfde menu ingedrukt.\n' \
                '_updates_aan_uit_menu, ' + str(callback_query)
     return message, []
开发者ID:RSDT,项目名称:bot2,代码行数:36,代码来源:menu.py

示例9: bug_done

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def bug_done(state):
    updates = Updates.get_updates()
    message = 'Er is bug gemeld.\n door: {van}\n aangeroepen met: '\
              '{command}\n het gaat over: {about}\n de text:\n {message}'
    message = message.format(van=state['from'], command=state['command'],
                             about=state['about'], message=state['message'])
    updates.error(Exception(message), 'bug_done')
    updates.bot.sendMessage(-158130982, message)
开发者ID:RSDT,项目名称:bot2,代码行数:10,代码来源:commands.py

示例10: _bug_menu

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
 def _bug_menu(self, update: Update, callback_query: str, rp_acc)->Tuple[str, List[InlineKeyboardButton]]:
     updates = Updates.get_updates()
     message = 'Er is bug gemeld.\n door: {van}\n aangeroepen met: ' \
               '{command}\n het gaat over: {about}\n de text:\n {message}'
     message = message.format(van=update.effective_user.name, command='bug menu',
                              about=self.path[-1], message='{message}')
     updates.error(Exception(message), 'bug_done')
     return 'er is gemeld dat je een bug hebt', []
开发者ID:RSDT,项目名称:bot2,代码行数:10,代码来源:menu.py

示例11: phpsessid_done

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def phpsessid_done(state):
    s = settings.Settings()
    u = Updates.get_updates()
    m = 'de phphsessid is aangepast van {old} naar {new}'
    u.error(Exception(m.format(old=str(s.phpsessid), new=str(state[
                                                                 'cookie']))),
            'php_sess_id')
    s.phpsessid = state['cookie']
开发者ID:RSDT,项目名称:bot2,代码行数:10,代码来源:commands.py

示例12: get_opdrachten

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def get_opdrachten():
    try:
        with requests.Session() as session:
            session.cookies.set('PHPSESSID', settings.Settings().phpsessid)
            r = session.get('http://www.jotihunt.net/groep/opdrachten.php')
            scraper = webscraper.TableHTMLParser()
            scraper.feed(r.text)
            scraper.fix_tables()
            # scraper.print_tables()
            with open('opdracht.log', 'w') as f:
                f.write(r.text)
            scraper.tables[0] = fix_opdrachten(scraper.tables[0])
            return (scraper.tables[0],
                   ['inzendtijd', 'title', 'punten'],
                   'title')
    except Exception as e:
        import Updates
        Updates.get_updates().error(e, 'get_opdrachten')
        return [], ['inzendtijd', 'title', 'punten'], 'title'
开发者ID:RSDT,项目名称:bot2,代码行数:21,代码来源:Jotihuntscraper.py

示例13: get_hunts

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def get_hunts():
    try:
        with requests.Session() as session:
            session.cookies.set('PHPSESSID', settings.Settings().phpsessid)
            r = session.get('http://www.jotihunt.net/groep/hunts.php')
            scraper = webscraper.TableHTMLParser()
            scraper.feed(r.text)
            with open('hunts.log', 'w') as f:
                f.write(r.text)
            scraper.fix_tables()
            # scraper.print_tables()
            return scraper.tables[0], ['hunttijd', 'meldtijd', 'code',
                                       'status', 'toelichting',
                                       'punten'], 'code'
    except Exception as e:
        import Updates
        Updates.get_updates().error(e, 'get_hunts')
        return [], ['hunttijd', 'meldtijd', 'code', 'status', 'toelichting',
                    'punten'], 'code'
开发者ID:RSDT,项目名称:bot2,代码行数:21,代码来源:Jotihuntscraper.py

示例14: sc_groep

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def sc_groep(bot: telegram.Bot, update: telegram.Update):
    """

    :param bot:
    :param update:
    :return:
    """
    chat_id = update.message.chat_id
    try:
        # TODO implement this
        # TODO add a keyboard
        bot.sendMessage(chat_id, 'Deze functie doet nog niks')
        Updates.get_updates().botan.track(update.message, 'groep')
    except MultipleConversationsError:
        bot.sendMessage(chat_id, "Er is al een commando actief je kunt dit "
                                 "commando niet starten.\n"
                                 " type /cancel om het vorige commando te "
                                 "stoppen te stoppen",
                        reply_to_message_id=update.message.message_id)
        Updates.get_updates().botan.track(update.message, 'incorrect_groep')
开发者ID:RSDT,项目名称:bot2,代码行数:22,代码来源:commands.py

示例15: bug_conversation

# 需要导入模块: import Updates [as 别名]
# 或者: from Updates import get_updates [as 别名]
def bug_conversation(bot: telegram.Bot, update: telegram.Update, state):
    s = state.get_state()
    if update.message.chat_id > 0:
        keyboard = telegram.ReplyKeyboardMarkup(DEFAULT_KEYBOARD)
    else:
        keyboard = telegram.ReplyKeyboardHide()
    if s == 0:
        state['about'] = update.message.text
        message = 'stuur nu je bug, feature, tip of top.'
        state.next_state()
    elif s == 1:
        state['message'] = update.message.text
        state.done()
        message = 'Je input is opgeslagen en doorgestuurd naar Bram Micky ' \
                  'en Mattijn (en evt. anderen).'
    else:
        message = ' dit is een fout in de bot graag aan mattijn laten weten,' \
                  'bug_conversation'
        Updates.get_updates().error(Exception(message), 'bug_conversation')
    bot.sendMessage(update.message.chat_id, message, reply_markup=keyboard)
开发者ID:RSDT,项目名称:bot2,代码行数:22,代码来源:commands.py


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