コード例 #1
0
 def test_filters_chat_username(self):
     self.assertFalse(Filters.chat(username='******')(self.message))
     self.message.chat.username = '******'
     self.assertTrue(Filters.chat(username='******')(self.message))
     self.assertTrue(Filters.chat(username='******')(self.message))
     self.assertTrue(Filters.chat(username=['chat1', 'chat', 'chat2'])(self.message))
     self.assertFalse(Filters.chat(username=['@chat1', 'chat_2'])(self.message))
コード例 #2
0
 def test_filters_chat_id(self):
     self.assertFalse(Filters.chat(chat_id=-1)(self.message))
     self.message.chat.id = -1
     self.assertTrue(Filters.chat(chat_id=-1)(self.message))
     self.message.chat.id = -2
     self.assertTrue(Filters.chat(chat_id=[-1, -2])(self.message))
     self.assertFalse(Filters.chat(chat_id=-1)(self.message))
コード例 #3
0
 def test_filters_chat_id(self, message):
     assert not Filters.chat(chat_id=-1)(message)
     message.chat.id = -1
     assert Filters.chat(chat_id=-1)(message)
     message.chat.id = -2
     assert Filters.chat(chat_id=[-1, -2])(message)
     assert not Filters.chat(chat_id=[-3, -4])(message)
コード例 #4
0
 def test_filters_user_id(self):
     self.assertFalse(Filters.user(user_id=1)(self.message))
     self.message.from_user.id = 1
     self.assertTrue(Filters.user(user_id=1)(self.message))
     self.message.from_user.id = 2
     self.assertTrue(Filters.user(user_id=[1, 2])(self.message))
     self.assertFalse(Filters.user(user_id=1)(self.message))
コード例 #5
0
 def test_filters_user_id(self, message):
     assert not Filters.user(user_id=1)(message)
     message.from_user.id = 1
     assert Filters.user(user_id=1)(message)
     message.from_user.id = 2
     assert Filters.user(user_id=[1, 2])(message)
     assert not Filters.user(user_id=[3, 4])(message)
コード例 #6
0
 def test_filters_chat_username(self, message):
     assert not Filters.chat(username='******')(message)
     message.chat.username = '******'
     assert Filters.chat(username='******')(message)
     assert Filters.chat(username='******')(message)
     assert Filters.chat(username=['chat1', 'chat', 'chat2'])(message)
     assert not Filters.chat(username=['@chat1', 'chat_2'])(message)
コード例 #7
0
 def test_inverted_filters(self, message):
     message.text = '/test'
     assert Filters.command(message)
     assert not (~Filters.command)(message)
     message.text = 'test'
     assert not Filters.command(message)
     assert (~Filters.command)(message)
コード例 #8
0
 def test_filters_reply(self, message):
     another_message = Message(1, User(1, 'TestOther', False), datetime.datetime.now(),
                               Chat(0, 'private'))
     message.text = 'test'
     assert not Filters.reply(message)
     message.reply_to_message = another_message
     assert Filters.reply(message)
コード例 #9
0
ファイル: rules_bot.py プロジェクト: bvanrijn/rules-bot
def main():
    config = configparser.ConfigParser()
    config.read('bot.ini')

    updater = Updater(token=config['KEYS']['bot_api'], use_context=True)
    dispatcher = updater.dispatcher

    global SELF_CHAT_ID
    SELF_CHAT_ID = f'@{updater.bot.get_me().username}'

    rate_limit_tracker_handler = MessageHandler(~Filters.command, rate_limit_tracker)

    start_handler = CommandHandler('start', start)
    rules_handler = CommandHandler('rules', rules)
    rules_handler_hashtag = MessageHandler(Filters.regex(r'.*#rules.*'), rules)
    docs_handler = CommandHandler('docs', docs)
    wiki_handler = CommandHandler('wiki', wiki)
    sandwich_handler = MessageHandler(Filters.regex(r'(?i)[\s\S]*?((sudo )?make me a sandwich)[\s\S]*?'),
                                      sandwich)
    off_on_topic_handler = MessageHandler(Filters.regex(r'(?i)[\s\S]*?\b(?<!["\\])(off|on)[- _]?topic\b'),
                                          off_on_topic)

    # We need several matches so Filters.regex is basically useless
    # therefore we catch everything and do regex ourselves
    # This should probably be in another dispatcher group
    # but I kept getting SystemErrors...
    github_handler = MessageHandler(Filters.text, github)
    forward_faq_handler = MessageHandler(Filters.regex(r'(?i).*#faq.*'), forward_faq)

    dispatcher.add_handler(rate_limit_tracker_handler, group=-1)

    # Note: Order matters!
    taghints.register(dispatcher)
    dispatcher.add_handler(forward_faq_handler)
    dispatcher.add_handler(start_handler)
    dispatcher.add_handler(rules_handler)
    dispatcher.add_handler(rules_handler_hashtag)
    dispatcher.add_handler(docs_handler)
    dispatcher.add_handler(wiki_handler)
    dispatcher.add_handler(sandwich_handler)
    dispatcher.add_handler(off_on_topic_handler)
    dispatcher.add_handler(github_handler)

    inlinequeries.register(dispatcher)
    dispatcher.add_error_handler(error)

    updater.start_polling()
    logger.info('Listening...')

    try:
        github_issues.set_auth(config['KEYS']['github_client_id'], config['KEYS']['github_client_secret'])
    except KeyError:
        logging.info('No github auth set. Rate-limit is 60 requests/hour without auth.')

    github_issues.init_issues(dispatcher.job_queue)

    updater.idle()
コード例 #10
0
    def test_entities_filter(self, message, message_entity):
        message.entities = [message_entity]
        assert Filters.entity(message_entity.type)(message)

        message.entities = []
        assert not Filters.entity(MessageEntity.MENTION)(message)

        second = message_entity.to_dict()
        second['type'] = 'bold'
        second = MessageEntity.de_json(second, None)
        message.entities = [message_entity, second]
        assert Filters.entity(message_entity.type)(message)
コード例 #11
0
    def test_entities_filter(self):
        self.message.entities = [self.e(MessageEntity.MENTION)]
        self.assertTrue(Filters.entity(MessageEntity.MENTION)(self.message))

        self.message.entities = []
        self.assertFalse(Filters.entity(MessageEntity.MENTION)(self.message))

        self.message.entities = [self.e(MessageEntity.BOLD)]
        self.assertFalse(Filters.entity(MessageEntity.MENTION)(self.message))

        self.message.entities = [self.e(MessageEntity.BOLD), self.e(MessageEntity.MENTION)]
        self.assertTrue(Filters.entity(MessageEntity.MENTION)(self.message))
コード例 #12
0
    def test_entities_filter(self):
        e = functools.partial(MessageEntity, offset=0, length=0)

        self.message.entities = [e(MessageEntity.MENTION)]
        self.assertTrue(Filters.entity(MessageEntity.MENTION)(self.message))

        self.message.entities = []
        self.assertFalse(Filters.entity(MessageEntity.MENTION)(self.message))

        self.message.entities = [e(MessageEntity.BOLD)]
        self.assertFalse(Filters.entity(MessageEntity.MENTION)(self.message))

        self.message.entities = [e(MessageEntity.BOLD), e(MessageEntity.MENTION)]
        self.assertTrue(Filters.entity(MessageEntity.MENTION)(self.message))
コード例 #13
0
    def test_and_or_filters(self):
        self.message.text = 'test'
        self.message.forward_date = True
        self.assertTrue((Filters.text & (Filters.forwarded | Filters.entity(MessageEntity.MENTION))
                        )(self.message))
        self.message.forward_date = False
        self.assertFalse((Filters.text & (Filters.forwarded | Filters.entity(MessageEntity.MENTION)
                                         ))(self.message))
        self.message.entities = [self.e(MessageEntity.MENTION)]
        self.assertTrue((Filters.text & (Filters.forwarded | Filters.entity(MessageEntity.MENTION))
                        )(self.message))

        self.assertEqual(
            str((Filters.text & (Filters.forwarded | Filters.entity(MessageEntity.MENTION)))),
            '<Filters.text and <Filters.forwarded or Filters.entity(mention)>>'
        )
コード例 #14
0
 def test_language_filter_multiple(self, message):
     f = Filters.language(['en_US', 'da'])
     message.from_user.language_code = 'en_US'
     assert f(message)
     message.from_user.language_code = 'en_GB'
     assert not f(message)
     message.from_user.language_code = 'da'
     assert f(message)
コード例 #15
0
 def test_language_filter_multiple(self):
     f = Filters.language(['en_US', 'da'])
     self.message.from_user.language_code = 'en_US'
     self.assertTrue(f(self.message))
     self.message.from_user.language_code = 'en_GB'
     self.assertFalse(f(self.message))
     self.message.from_user.language_code = 'da'
     self.assertTrue(f(self.message))
コード例 #16
0
    def test_and_filters(self):
        self.message.text = 'test'
        self.message.forward_date = True
        self.assertTrue((Filters.text & Filters.forwarded)(self.message))
        self.message.text = '/test'
        self.assertFalse((Filters.text & Filters.forwarded)(self.message))
        self.message.text = 'test'
        self.message.forward_date = None
        self.assertFalse((Filters.text & Filters.forwarded)(self.message))

        self.message.text = 'test'
        self.message.forward_date = True
        self.message.entities = [self.e(MessageEntity.MENTION)]
        self.assertTrue((Filters.text & Filters.forwarded & Filters.entity(MessageEntity.MENTION))(
            self.message))
        self.message.entities = [self.e(MessageEntity.BOLD)]
        self.assertFalse((Filters.text & Filters.forwarded & Filters.entity(MessageEntity.MENTION)
                         )(self.message))
コード例 #17
0
    def test_and_or_filters(self):
        self.message.text = 'test'
        self.message.forward_date = True
        self.assertTrue((Filters.text & (Filters.forwarded | Filters.entity(MessageEntity.MENTION))
                        )(self.message))
        self.message.forward_date = False
        self.assertFalse((Filters.text & (Filters.forwarded | Filters.entity(MessageEntity.MENTION)
                                         ))(self.message))
        self.message.entities = [self.e(MessageEntity.MENTION)]
        self.assertTrue((Filters.text & (Filters.forwarded | Filters.entity(MessageEntity.MENTION))
                        )(self.message))

        self.assertRegexpMatches(
            str((Filters.text & (Filters.forwarded | Filters.entity(MessageEntity.MENTION)))),
            r"<telegram.ext.filters.MergedFilter consisting of <telegram.ext.filters.(Filters.)?_"
            r"Text object at .*?> and <telegram.ext.filters.MergedFilter consisting of "
            r"<telegram.ext.filters.(Filters.)?_Forwarded object at .*?> or "
            r"<telegram.ext.filters.(Filters.)?entity object at .*?>>>")
コード例 #18
0
 def test_language_filter_single(self, message):
     message.from_user.language_code = 'en_US'
     assert (Filters.language('en_US'))(message)
     assert (Filters.language('en'))(message)
     assert not (Filters.language('en_GB'))(message)
     assert not (Filters.language('da'))(message)
     message.from_user.language_code = 'da'
     assert not (Filters.language('en_US'))(message)
     assert not (Filters.language('en'))(message)
     assert not (Filters.language('en_GB'))(message)
     assert (Filters.language('da'))(message)
コード例 #19
0
    def test_and_or_filters(self, message):
        message.text = 'test'
        message.forward_date = True
        assert (Filters.text & (Filters.forwarded | Filters.status_update))(message)
        message.forward_date = False
        assert not (Filters.text & (Filters.forwarded | Filters.status_update))(message)
        message.pinned_message = True
        assert (Filters.text & (Filters.forwarded | Filters.status_update)(message))

        assert str((Filters.text & (Filters.forwarded | Filters.entity(
            MessageEntity.MENTION)))) == '<Filters.text and <Filters.forwarded or ' \
                                         'Filters.entity(mention)>>'
コード例 #20
0
 def test_filters_username(self):
     self.assertFalse(Filters.user(username='******')(self.message))
     self.assertFalse(Filters.user(username='******')(self.message))
     self.message.from_user.username = '******'
     self.assertTrue(Filters.user(username='******')(self.message))
     self.assertTrue(Filters.user(username='******')(self.message))
     self.assertTrue(Filters.user(username=['user1', 'user', 'user2'])(self.message))
     self.assertFalse(Filters.user(username=['@username', '@user_2'])(self.message))
コード例 #21
0
 def test_filters_username(self, message):
     assert not Filters.user(username='******')(message)
     assert not Filters.user(username='******')(message)
     message.from_user.username = '******'
     assert Filters.user(username='******')(message)
     assert Filters.user(username='******')(message)
     assert Filters.user(username=['user1', 'user', 'user2'])(message)
     assert not Filters.user(username=['@username', '@user_2'])(message)
コード例 #22
0
ファイル: telegram_bot.py プロジェクト: idlesign/torrt
    def __init__(self, token, allowed_users=None):
        """
        :param token: str - Telegram's bot token
        :param allowed_users: str - comma-joined list of users allowed to add new torrents.
        """
        if not telegram:
            LOGGER.error('You have not installed python-telegram-bot library.')
            return

        self.token = token
        self.allowed_users = allowed_users or ''
        self.handler_kwargs = {}
        self.updater = Updater(token=self.token)
        self.dispatcher = self.updater.dispatcher
        if self.allowed_users:
            self.handler_kwargs = {'filters': Filters.user(username=self.allowed_users.split(','))}
コード例 #23
0
ファイル: test_filters.py プロジェクト: technoekat/prodeda1
    def test_filters_regex(self, message):
        message.text = '/start deep-linked param'
        assert Filters.regex(r'deep-linked param')(message)
        message.text = '/help'
        assert Filters.regex(r'help')(message)
        message.text = '/help'
        assert Filters.regex('help')(message)

        message.text = 'test'
        assert not Filters.regex(r'fail')(message)
        assert Filters.regex(r'test')(message)
        assert Filters.regex(re.compile(r'test'))(message)

        message.text = 'i love python'
        assert Filters.regex(r'.\b[lo]{2}ve python')(message)
コード例 #24
0
ファイル: menu.py プロジェクト: org97/incredible-citizen-bot
def unknown(update: Update, context: CallbackContext):
    context.bot.send_message(chat_id=update.effective_chat.id,
                             text=s.menu_unknown,
                             reply_markup=default_markup)
    return ConversationHandler.END


def main_menu(update: Update, context: CallbackContext):
    message = update.message
    message.from_user.send_message(s.got_it, reply_markup=default_markup)
    return ConversationHandler.END


conv_handler = ConversationHandler(
    entry_points=[MessageHandler(Filters.regex('^%s$' % s.menu), menu)],
    states={
        START: [
            CallbackQueryHandler(menu, pattern='^menu$'),
            MessageHandler(Filters.regex('^%s$' % s.back), main_menu),
            MessageHandler(Filters.regex('^%s$' % s.update_city), update_city),
            MessageHandler(Filters.regex('^%s$' % s.how_does_it_work),
                           how_does_it_work),
            MessageHandler(Filters.regex('^%s$' % s.feedback), feedback),
        ],
        UPDATING_CITY: [
            # going back from the list of regional cities
            CallbackQueryHandler(update_city, pattern='^select_city_1$'),
            # selecting a region
            CallbackQueryHandler(update_city_2, pattern='^select_city_2$'),
            # selecting a city by region
コード例 #25
0
            filename="chatlist.txt",
            caption="Here is the list of chats in my database.")


def __user_info__(user_id, chat_id):
    if user_id == dispatcher.bot.id:
        return languages.tl(chat_id, """I have seen it... Wow. Are they following me? They're in all the same places with me... oh. This is me.""")
    num_chats = sql.get_user_num_chats(user_id)
    return languages.tl(chat_id, """I've seen them in <code>{}</code> chats in total.""").format(num_chats)


def __stats__():
    return languages.tl(OWNER_ID, "`{}` users, on `{}` chats").format(sql.num_users(), sql.num_chats())


def __migrate__(old_chat_id, new_chat_id):
    sql.migrate_chat(old_chat_id, new_chat_id)


__help__ = ""  # no help string

__mod_name__ = "Users"

BROADCAST_HANDLER = CommandHandler("broadcast", broadcast, filters=Filters.user(OWNER_ID))
USER_HANDLER = MessageHandler(Filters.all & Filters.group, log_user)
CHATLIST_HANDLER = CommandHandler("chatlist", chats, filters=CustomFilters.sudo_filter)

dispatcher.add_handler(USER_HANDLER, USERS_GROUP)
dispatcher.add_handler(BROADCAST_HANDLER)
dispatcher.add_handler(CHATLIST_HANDLER)
コード例 #26
0
            parse_mode=ParseMode.MARKDOWN)


# /ip is for private use
__help__ = """
 - /id: get the current group id. If used by replying to a message, gets that user's id.
 - /info: get information about a user.
 - /markdownhelp: quick summary of how markdown works in telegram - can only be called in private chats.
 - /stickerid: reply to a sticker and get sticker id of that.
 - /getsticker: reply to a sticker and get that sticker as .png and image. 
"""

__mod_name__ = "Misc"

ID_HANDLER = DisableAbleCommandHandler("id", get_id, pass_args=True)
IP_HANDLER = CommandHandler("ip", get_bot_ip, filters=Filters.chat(OWNER_ID))
INFO_HANDLER = DisableAbleCommandHandler("info", info, pass_args=True)
MD_HELP_HANDLER = CommandHandler("markdownhelp",
                                 markdown_help,
                                 filters=Filters.private)

STICKERID_HANDLER = DisableAbleCommandHandler("stickerid", stickerid)
GETSTICKER_HANDLER = DisableAbleCommandHandler("getsticker", getsticker)

dispatcher.add_handler(ID_HANDLER)
dispatcher.add_handler(IP_HANDLER)
dispatcher.add_handler(INFO_HANDLER)
dispatcher.add_handler(MD_HELP_HANDLER)
dispatcher.add_handler(STICKERID_HANDLER)
dispatcher.add_handler(GETSTICKER_HANDLER)
コード例 #27
0
ファイル: main.py プロジェクト: pdpfsug/Google_calendar_bot
def main():
    print("---Starting bot---")

    # Initialize the bot
    updater = Updater(TOKEN, use_context=True)
    dispatcher = updater.dispatcher

    # Add command handlers
    dispatcher.add_handler(CommandHandler('start', start))

    # Create new conversation handler
    dispatcher.add_handler(
        ConversationHandler(
            # Conversation start from this handler
            entry_points=[CommandHandler('create_event', create_event)],

            # Defines the different states of conversation a user can be in
            states={
                # Filter messages looking just for text
                TITLE: [MessageHandler(Filters.text, check_title)],

                # Filter messages looking for date (31/12/19)
                START_DATE: [
                    MessageHandler(Filters.regex('[0-9]{2}-[0-9]{2}-[0-9]{2}'),
                                   check_start_date)
                ],

                # Filter messages looking for time (09:00)
                START_TIME: [
                    MessageHandler(Filters.regex('[0-9]{2}:[0-9]{2}'),
                                   check_start_time)
                ],

                # Filter messages looking for date (31/12/19)
                END_DATE: [
                    MessageHandler(Filters.regex('[0-9]{2}-[0-9]{2}-[0-9]{2}'),
                                   check_end_date)
                ],

                # Filter messages looking for time (09:00)
                END_TIME: [
                    MessageHandler(Filters.regex('[0-9]{2}:[0-9]{2}'),
                                   check_end_time)
                ],

                # Filter messages looking just for text
                DESCRIPTION: [MessageHandler(Filters.text, check_description)],

                # Filter messages for text
                LOCATION: [MessageHandler(Filters.text, check_location)],
            },

            # A list of handlers that might be used if the user is in a conversation,
            # but every handler for their current state returned
            fallbacks=[CommandHandler('cancel', cancel)],

            # Determines if a user can restart a conversation with an entry point
            allow_reentry=True))

    # Start bot
    updater.start_polling()
    updater.idle()
コード例 #28
0

#Security
def security(update, context):
    context.bot.send_message(
        chat_id=update.effective_chat.id,
        text=
        "You appear to be using an account not associated with any of the SMUX EXCOs, please email [email protected] with your Unique ID if you believe this is a mistake. \n\n Your Unique ID is: "
        + str(update.effective_chat.id))


list_of_exco = []
user = db.child('EXCO').get().val()
for uid in user.values():
    list_of_exco.append(uid)
security_handler = MessageHandler(~Filters.chat(chat_id=list_of_exco),
                                  security)

#Token
load_dotenv('.env')
updater = Updater(token=os.getenv('SMUX_EXCO_BOT_TOKEN'), use_context=True)
dispatcher = updater.dispatcher
dispatcher.add_handler(security_handler)


#Start
def start(update, context):
    valid_user = False
    for user in list_of_exco:
        if (update.effective_chat.id == user):
            valid_user = True
コード例 #29
0
                text = re.sub(repl, repl_with, to_fix, flags=re.I).strip()
            elif "i" in flags:
                text = re.sub(repl, repl_with, to_fix, count=1,
                              flags=re.I).strip()
            elif "g" in flags:
                text = re.sub(repl, repl_with, to_fix).strip()
            else:
                text = re.sub(repl, repl_with, to_fix, count=1).strip()
        except sre_constants.error:
            LOGGER.warning(update.effective_message.text)
            LOGGER.exception("SRE constant error")
            update.effective_message.reply_text(
                "Do you even sed? Apparently not.")
            return

        # empty string errors -_-
        if len(text) >= telegram.MAX_MESSAGE_LENGTH:
            update.effective_message.reply_text(
                "The result of the sed command was too long for \
                                                 telegram!")
        elif text:
            update.effective_message.reply_to_message.reply_text(text)


SED_HANDLER = DisableAbleMessageHandler(Filters.regex(r"s([{}]).*?\1.*".format(
    "".join(DELIMITERS))),
                                        sed,
                                        friendly="sed")

dispatcher.add_handler(SED_HANDLER)
コード例 #30
0
ファイル: bot.py プロジェクト: mikekurkin/songspleet-tg-bot
from pydub import AudioSegment

from spleeter.separator import Separator
separator = Separator('spleeter:2stems')

import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                     level=logging.INFO)
logger = logging.getLogger('bot')

import yaml
config = {}

filters = {
    'admins': Filters.chat(username=[], allow_empty=False),
    'authorized' : Filters.chat(username=[], allow_empty=True)
}

def loadconfig():
    configfile = os.path.join('.', 'config.yaml')
    if os.path.isfile(configfile):
        with open(configfile) as f:
            config = yaml.load(f, Loader=yaml.FullLoader)
    logger.info(f"Config loaded: {str (config)}")
    for key in filters:
        update_filter(config.get(key, []), filters[key])
    
    logger.info(f"Authorized: {str (filters['authorized'].usernames)}; Admins: {str (filters['admins'].usernames)}")
    
コード例 #31
0
    sql.rm_afk(user_id)


__help__ = """
 - /afk <reason>: mark yourself as AFK(away from keyboard).
 - brb <reason>: same as the afk command - but not a command.
When marked as AFK, any mentions will be replied to with a message to say you're not available!
"""

AFK_HANDLER = DisableAbleCommandHandler("afk", afk)
AFK_REGEX_HANDLER = DisableAbleRegexHandler(r"(?i)brb", afk, friendly="afk")
NO_AFK_HANDLER = DisableAbleMessageHandler(Filters.all & Filters.group,
                                           no_longer_afk,
                                           friendly="afk")
AFK_REPLY_HANDLER = DisableAbleMessageHandler(
    (Filters.entity(MessageEntity.MENTION)
     | Filters.entity(MessageEntity.TEXT_MENTION)) & Filters.group,
    reply_afk,
    friendly="afk")

dispatcher.add_handler(AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REGEX_HANDLER, AFK_GROUP)
dispatcher.add_handler(NO_AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REPLY_HANDLER, AFK_REPLY_GROUP)

__mod_name__ = "AFK"
__command_list__ = ["afk"]
__handlers__ = [(AFK_HANDLER, AFK_GROUP), (AFK_REGEX_HANDLER, AFK_GROUP),
                (NO_AFK_HANDLER, AFK_GROUP),
                (AFK_REPLY_HANDLER, AFK_REPLY_GROUP)]
コード例 #32
0
def main():
    mybot = Updater(settings.API_KEY,
                    request_kwargs=settings.PROXY,
                    use_context=True)
    logging.info('Бот запустился')
    dp = mybot.dispatcher
    cqh = CallbackQueryHandler
    mh = MessageHandler
    dp.add_handler(CommandHandler("start", greet_user, pass_user_data=True))
    dp.add_handler(
        mh(Filters.regex('({})'.format(type_l).format(weapon_l)),
           i_know_weapon,
           pass_user_data=True))
    dp.add_handler(
        cqh(i_know_what_i_want,
            pass_user_data=True,
            pattern='i_know_what_i_want'))
    dp.add_handler(cqh(xur_keyboard, pass_user_data=True, pattern='xur'))
    dp.add_handler(cqh(all_xur, pass_user_data=True, pattern='all_xur'))
    dp.add_handler(cqh(xur_here, pass_user_data=True, pattern='xur_here'))
    dp.add_handler(cqh(exotic_keyboard, pass_user_data=True, pattern='exotic'))
    #dp.add_handler(cqh(, pass_user_data=True, pattern = 'raids'))
    dp.add_handler(cqh(armory_keyboard, pass_user_data=True, pattern='armory'))
    dp.add_handler(cqh(events_keyboard, pass_user_data=True, pattern='events'))
    #dp.add_handler(cqh(, pass_user_data=True, pattern = 'other'))
    for event in event_list:
        dp.add_handler(cqh(get_event, pass_user_data=True, pattern=event))
    dp.add_handler(
        cqh(events_keyboard, pass_user_data=True, pattern='events_keyboard'))
    dp.add_handler(
        cqh(key_keyboard, pass_user_data=True, pattern='key_keyboard'))

    dp.add_handler(cqh(exot_weapon, pass_user_data=True,
                       pattern='exot_weapon'))
    for weapon in exotic_guns:
        dp.add_handler(
            cqh(get_exotic_weapon, pass_user_data=True, pattern=weapon))

    dp.add_handler(
        cqh(kinetic_exotic, pass_user_data=True, pattern='kinetic_exotic'))
    dp.add_handler(
        cqh(energo_exotic, pass_user_data=True, pattern='energo_exotic'))
    dp.add_handler(
        cqh(heavy_exotic, pass_user_data=True, pattern='heavy_exotic'))

    dp.add_handler(cqh(exot_armor, pass_user_data=True, pattern='exot_armor'))
    for armor in exotic_armor:
        dp.add_handler(
            cqh(get_exotic_armor, pass_user_data=True, pattern=armor))

    dp.add_handler(
        CallbackQueryHandler(titan_exotic,
                             pass_user_data=True,
                             pattern='titan_exotic'))
    dp.add_handler(
        CallbackQueryHandler(warlock_exotic,
                             pass_user_data=True,
                             pattern='warlock_exotic'))
    dp.add_handler(
        CallbackQueryHandler(hunter_exotic,
                             pass_user_data=True,
                             pattern='hunter_exotic'))

    mybot.start_polling()
    mybot.idle()
コード例 #33
0
    'voice':
    Filters.voice,
    'document':
    Filters.document & ~Filters.animation,
    'video':
    Filters.video,
    'videonote':
    Filters.video_note,
    'contact':
    Filters.contact,
    'photo':
    Filters.photo,
    'gif':
    Filters.animation,
    'url':
    Filters.entity(MessageEntity.URL)
    | Filters.caption_entity(MessageEntity.URL),
    'bots':
    Filters.status_update.new_chat_members,
    'forward':
    Filters.forwarded,
    'game':
    Filters.game,
    'location':
    Filters.location,
}

GIF = Filters.animation
OTHER = Filters.game | Filters.sticker | GIF
MEDIA = Filters.audio | Filters.document | Filters.video | Filters.voice | Filters.photo
MESSAGES = Filters.text | Filters.contact | Filters.location | Filters.venue | Filters.command | MEDIA | OTHER
コード例 #34
0
__help__ = f"""
Chatbot utilizes the CoffeeHouse API and allows Saitama to talk and provides a more interactive group chat experience.

*Commands:* 
*Admins only:*
 • `/addchat`*:* Enables Chatbot mode in the chat.
 • `/rmchat`*:* Disables Chatbot mode in the chat.

Reports bugs at @{SUPPORT_CHAT}
*Powered by CoffeeHouse* (https://coffeehouse.intellivoid.net/) from @Intellivoid
"""

ADD_CHAT_HANDLER = CommandHandler("addchat", add_chat)
REMOVE_CHAT_HANDLER = CommandHandler("rmchat", remove_chat)
CHATBOT_HANDLER = MessageHandler(
    Filters.text & (~Filters.regex(r"^#[^\s]+") & ~Filters.regex(r"^!")
                    & ~Filters.regex(r"^\/")), chatbot)
LIST_CB_CHATS_HANDLER = CommandHandler("listaichats",
                                       list_chatbot_chats,
                                       filters=CustomFilters.dev_filter)
# Filters for ignoring #note messages, !commands and sed.

dispatcher.add_handler(ADD_CHAT_HANDLER)
dispatcher.add_handler(REMOVE_CHAT_HANDLER)
dispatcher.add_handler(CHATBOT_HANDLER)
dispatcher.add_handler(LIST_CB_CHATS_HANDLER)

__mod_name__ = "Chatbot"
__command_list__ = ["addchat", "rmchat", "listaichats"]
__handlers__ = [
    ADD_CHAT_HANDLER, REMOVE_CHAT_HANDLER, CHATBOT_HANDLER,
コード例 #35
0
                                                  filters=Filters.group,
                                                  pass_args=True,
                                                  admin_ok=True)
ADD_URL_BLACKLIST_HANDLER = CommandHandler("addurl",
                                           add_blacklist_url,
                                           filters=Filters.group)

RM_BLACKLIST_URL_HANDLER = CommandHandler("delurl",
                                          rm_blacklist_url,
                                          filters=Filters.group)

GET_BLACKLISTED_URLS = CommandHandler("geturl",
                                      get_blacklisted_urls,
                                      filters=Filters.group)

URL_DELETE_HANDLER = MessageHandler(Filters.entity("url"),
                                    del_blacklist_url,
                                    edited_updates=True)

__mod_name__ = "Domain Blacklists"

__help__ = """
Domain blacklisting is used to stop certain domains from being mentioned in a group, Any time an url on that domain is mentioned, /
the message will immediately be deleted.

*NOTE:* domain blacklisting do not affect group admins.

- /geturl: View the current blacklisted urls

*Admin only:*
コード例 #36
0
                    if not reason:
                        res = "{} is AFK!".format(fst_name)
                    else:
                        res = "{} is AFK! says its because of:\n{}".format(fst_name, reason)
                    message.reply_text(res)


def __gdpr__(user_id):
    sql.rm_afk(user_id)


__help__ = """
 ◉ /afk <reason> : mark yourself as AFK.
 ◉ brb <reason> : same as the afk command - but not a command.

When marked as AFK, any mentions will be replied to with a message to say you're not available!
"""

__mod_name__ = "AFK"

AFK_HANDLER = DisableAbleCommandHandler("afk", afk)
AFK_REGEX_HANDLER = DisableAbleRegexHandler("(?i)brb", afk, friendly="afk")
NO_AFK_HANDLER = MessageHandler(Filters.all & Filters.group, no_longer_afk)
AFK_REPLY_HANDLER = MessageHandler(Filters.entity(MessageEntity.MENTION) | Filters.entity(MessageEntity.TEXT_MENTION),
                                   reply_afk)

dispatcher.add_handler(AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REGEX_HANDLER, AFK_GROUP)
dispatcher.add_handler(NO_AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REPLY_HANDLER, AFK_REPLY_GROUP)
コード例 #37
0
ファイル: decr8_bot.py プロジェクト: Davicii-ii/musicloud
def main():
    # Create the Updater and pass it your bot's token.
    # Make sure to set use_context=True to use the new context based callbacks
    # Post version 12 this will no longer be necessary
    updater = Updater(
        "1266125805:AAFnUPiqc0LiHPWJNlOp2XhfSGsqtu_cEbA", use_context=True
    )
    
    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # Register a deep-linking handler
    dp.add_handler(
        CommandHandler(
            "start",
            deep_linked_level_1,
            Filters.regex(DECR8)
        )
    )
    
    # This one works with a textual link instead of an URL
    dp.add_handler(
        CommandHandler(
            "start",
            deep_linked_level_2,
            Filters.regex(SO_COOL)
        )
    )

    # We can also pass on the deep-linking payload
    dp.add_handler(
        CommandHandler(
            "start",
            deep_linked_level_3,
            Filters.regex(USING_ENTITIES),
            pass_args=True
        )
    )

    # Add conversation handler with the states GENDER, PHOTO, LOCATION and BIO
    conv_handler = ConversationHandler(
        entry_points=[CommandHandler('start', start)],
        states={
            STAGE1: [MessageHandler(Filters.regex('^(/start|/queue|/cancel)$'), stage1)],
            STAGE3: [
                MessageHandler(Filters.location, stage3),
                CommandHandler('skip', stage3),
            ],
            STAGE4: [MessageHandler(Filters.text & ~Filters.command, stage4)],
        },
        fallbacks=[CommandHandler('cancel', cancel)],
    )
    
    # on different commands - answer in Telegram
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("queue", queue))
    dp.add_handler(CommandHandler("add", add))
    dp.add_handler(CommandHandler("sub", sub))
    
    dp.add_handler(CommandHandler("help", help_command))
    dp.add_handler(CommandHandler("bad_command", bad_command))
    
    # on noncommand i.e message - echo the message on Telegram
    dp.add_handler(InlineQueryHandler(inlinequery))
    dp.add_handler(MessageHandler(Filters.text & ~Filters.command, search))
    dp.add_handler(CallbackQueryHandler(button))    
    dp.add_handler(conv_handler)
    dp.add_error_handler(error_handler)

    # Start the Bot
    updater.start_polling()
    
    # Block until the user presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()    
コード例 #38
0
                chat_id=query.message.chat_id,
                parse_mode=ParseMode.HTML)
            query.answer("🛑 Failed to delete message!")


__help__ = """
 • `/report <reason>`*:* reply to a message to report it to admins.
 • `@admin`*:* reply to a message to report it to admins.
*NOTE:* Neither of these will get triggered if used by admins.

*Admins only:*
 • `/reports <on/off>`*:* change report setting, or view current status.
   • If done in pm, toggles your status.
   • If in group, toggles that groups's status.
"""

SETTING_HANDLER = CommandHandler("reports", report_setting)
REPORT_HANDLER = CommandHandler("report", report, filters=Filters.group)
ADMIN_REPORT_HANDLER = MessageHandler(Filters.regex(r"(?i)@admin(s)?"), report)

REPORT_BUTTON_USER_HANDLER = CallbackQueryHandler(buttons, pattern=r"report_")
dispatcher.add_handler(REPORT_BUTTON_USER_HANDLER)

dispatcher.add_handler(SETTING_HANDLER)
dispatcher.add_handler(REPORT_HANDLER, REPORT_GROUP)
dispatcher.add_handler(ADMIN_REPORT_HANDLER, REPORT_GROUP)

__mod_name__ = "Reporting"
__handlers__ = [(REPORT_HANDLER, REPORT_GROUP),
                (ADMIN_REPORT_HANDLER, REPORT_GROUP), (SETTING_HANDLER)]
コード例 #39
0
ファイル: notes.py プロジェクト: NehemiahAklil/CanisSimensis
 - /notes or /saved: list all saved notes in this chat

If you would like to retrieve the contents of a note without any formatting, use `/get <notename> noformat`. This can \
be useful when updating a current note.

*Admin only:*
 - /save <notename> <notedata>: saves notedata as a note with name notename
A button can be added to a note by using standard markdown link syntax - the link should just be prepended with a \
`buttonurl:` section, as such: `[somelink](buttonurl:example.com)`. Check /markdownhelp for more info.
 - /save <notename>: save the replied message as a note with name notename
 - /clear <notename>: clear note with this name
"""

__mod_name__ = "Notes"

GET_HANDLER = CommandHandler("get", cmd_get, pass_args=True)
HASH_GET_HANDLER = MessageHandler(Filters.regex(r"^#[^\s]+"), hash_get)

SAVE_HANDLER = CommandHandler("save", save)
DELETE_HANDLER = CommandHandler("clear", clear, pass_args=True)

LIST_HANDLER = DisableAbleCommandHandler(["notes", "saved"],
                                         list_notes,
                                         admin_ok=True)

dispatcher.add_handler(GET_HANDLER)
dispatcher.add_handler(SAVE_HANDLER)
dispatcher.add_handler(LIST_HANDLER)
dispatcher.add_handler(DELETE_HANDLER)
dispatcher.add_handler(HASH_GET_HANDLER)
コード例 #40
0
 def test_filters_photo(self, message):
     assert not Filters.photo(message)
     message.photo = 'test'
     assert Filters.photo(message)
コード例 #41
0

def cancel(update: Update, _: CallbackContext) -> int:
    logger.info("Conversation canceled.")

    update.message.reply_text(
        "Bye! I hope we can talk again some day.",
        reply_markup=ReplyKeyboardRemove(),
    )
    return ConversationHandler.END


MENU_HANDLER = MessageHandler(
    Filters.regex(
        "^(Begin|💵 Current value|📈 Progress|➗ Current ratios|🔍 Check bot status|⌛ Trade History|🛠 Maintenance|"
        "⚙️ Configurations|▶ Start trade bot|⏹ Stop trade bot|📜 Read last log lines|❌ Delete database|"
        "⚙ Edit user.cfg|👛 Edit coin list|📤 Export database|Update Telegram Bot|Update Binance Trade Bot|"
        "⬅️ Back|Go back|OK|Cancel update|OK 👌)$"),
    menu,
)

ENTRY_POINT_HANDLER = CommandHandler(
    "start", start, Filters.user(user_id=eval(settings.USER_ID)))

EDIT_COIN_LIST_HANDLER = MessageHandler(Filters.regex("(.*?)"), edit_coin)

EDIT_USER_CONFIG_HANDLER = MessageHandler(Filters.regex("(.*?)"),
                                          edit_user_config)

DELETE_DB_HANDLER = MessageHandler(Filters.regex("^(⚠ Confirm|Go back)$"),
                                   delete_db)
コード例 #42
0
 def test_filters_video(self, message):
     assert not Filters.video(message)
     message.video = 'test'
     assert Filters.video(message)
コード例 #43
0
    is_admin = False
    for i in context.bot.getChatAdministrators(update.message.chat_id):
        if update.message.from_user.id == i.user.id:
            is_admin = True
        elif update.message.from_user.id == cnf.chat_id:
            is_admin = True

    if is_admin:
        text_ts = ''
        for row in dbm.all_q_a():
            text_ts = text_ts + '\n' + row[0] + ' --> ' + (' '.join(
                eval(row[1])).replace("!!", "(nl)"))
        update.message.reply_text(text_ts)


updater = Updater(token=cnf.token, use_context=True)
updater.dispatcher.add_handler(CommandHandler("start", start_callback))
updater.dispatcher.add_handler(CommandHandler("add", set_qa_function))
updater.dispatcher.add_handler(CommandHandler("start", start_callback))
updater.dispatcher.add_handler(CommandHandler('google', google_boy))
updater.dispatcher.add_handler(CommandHandler('stack', stackof_boy))
updater.dispatcher.add_handler(CommandHandler("free", free_command))
updater.dispatcher.add_handler(CommandHandler("rm", qa_deleter))
updater.dispatcher.add_handler(CommandHandler("list", qa_lister))
updater.dispatcher.add_handler(
    MessageHandler(Filters.regex(('!\w+')), qa_manager))
updater.dispatcher.add_handler(
    MessageHandler(Filters.status_update, welcome_function))
print("running")
updater.start_polling()
updater.idle()
コード例 #44
0
 def test_filters_contact(self, message):
     assert not Filters.contact(message)
     message.contact = 'test'
     assert Filters.contact(message)
コード例 #45
0
`goodmorning`, `good morning` or `goodnight`, `good night`.

Suzuya will reply random strings accordingly when these words are used!
All regex filters can be disabled incase u don't want... like: `/disable goodnight`.

"""

__mod_name__ = "Memes"

PAT_HANDLER = DisableAbleCommandHandler("pat", pat)
SHOUT_HANDLER = DisableAbleCommandHandler("shout", shout)
DARE_HANDLER = DisableAbleCommandHandler("dare", dare)
TRUTH_HANDLER = DisableAbleCommandHandler("truth", truth)
SANITIZE_HANDLER = DisableAbleCommandHandler("sanitize", sanitize)
SHRUG_HANDLER = DisableAbleCommandHandler("shrug", shrug)
DECIDE_HANDLER = DisableAbleMessageHandler(Filters.regex(r"(?i)(Liza|liza)"),
                                           decide,
                                           friendly="decide")
ABUSE_HANDLER = DisableAbleCommandHandler("abuse", abuse, pass_args=True)
RUNS_HANDLER = DisableAbleCommandHandler("runs", runs, pass_args=True)
SLAP_HANDLER = DisableAbleCommandHandler("slap", slap)
HUG_HANDLER = DisableAbleCommandHandler("hug", hug)
GBUN_HANDLER = CommandHandler("gbun", gbun)
GBAM_HANDLER = CommandHandler("gbam", gbam)
TABLE_HANDLER = DisableAbleCommandHandler("table", table)
CRI_HANDLER = DisableAbleCommandHandler("cri", cri)
PASTA_HANDLER = DisableAbleCommandHandler("pasta", copypasta)
CLAP_HANDLER = DisableAbleCommandHandler("clap", clapmoji)
OWO_HANDLER = DisableAbleCommandHandler("owo", owo)
STRECH_HANDLER = DisableAbleCommandHandler("stretch", stretch)
RECITE_HANDLER = DisableAbleCommandHandler("recite", recite)
コード例 #46
0
ファイル: taghints.py プロジェクト: bvanrijn/rules-bot
def register(dispatcher):
    dispatcher.add_handler(MessageHandler(Filters.regex(rf'{"|".join(HINTS.keys())}.*'), hint_handler))
    dispatcher.add_handler(CommandHandler(('hints', 'listhints'), list_available_hints))
コード例 #47
0
ファイル: Settings.py プロジェクト: socialrupt/Project2
def done(update: Update, context: CallbackContext) -> int:

    update.message.reply_text("BYE BYE!!")

    return ConversationHandler.END


#-----------------------------------------------------------------

#========================================================

conv_handler = ConversationHandler(
    entry_points=[
        CommandHandler(
            'start', start,
            Filters.user(username=UserName_Of_Owner)
            & Filters.chat_type.private)
    ],  #make this the username
    states={
        Waiting_For_User_Choice: [
            MessageHandler(Filters.regex('^({})$'.format(Group_1_Username)),
                           Group_1),
        ],
        #===================================================================
        Waiting_For_Choice_Group1_Settings: [
            MessageHandler(Filters.regex('^(Premium Settings)$'),
                           start_in_Group1_Premium_Settings),
            MessageHandler(Filters.regex("Change"),
                           start_in_Group1_GroupFormat_Settings),
            MessageHandler(Filters.regex("^(AutoDrop Settings)$"),
                           start_in_Group1_AutoDrop_Settings),
コード例 #48
0
            (time.time() - float(REDIS.get(f"afk_time_{user_id}")))
        )
        text = "<i>This user is currently afk (away from keyboard).</i>"
        text += f"\n<i>Since: {since_afk}</i>"

    else:
        text = "<i>This user is currently isn't afk (away from keyboard).</i>"
    return text


def __gdpr__(user_id):
    end_afk(user_id)


__mod_name__ = "AFK"


AFK_HANDLER = DisableAbleCommandHandler("afk", afk, run_async=True)
AFK_REGEX_HANDLER = MessageHandler(Filters.regex("(?i)brb"), afk, run_async=True)
NO_AFK_HANDLER = MessageHandler(
    Filters.all & Filters.chat_type.groups, no_longer_afk, run_async=True
)
AFK_REPLY_HANDLER = MessageHandler(
    Filters.all & Filters.chat_type.groups, reply_afk, run_async=True
)

dispatcher.add_handler(AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REGEX_HANDLER, AFK_GROUP)
dispatcher.add_handler(NO_AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REPLY_HANDLER, AFK_REPLY_GROUP)
コード例 #49
0
    for job in job_queue.get_jobs_by_name(str(message.message_id)):
        job.context["time_left"] = None
    return ConversationHandler.END


# ---------------------------------------------------------------------------- #
#                               Bot handler setup                              #
# ---------------------------------------------------------------------------- #

greet_command_handler = CommandHandler("greet", greet, run_async=True)
get_schedule_command_handler = ConversationHandler(
    entry_points=[CommandHandler("list", get_scheduled_messages)],
    states={},
    fallbacks=[
        MessageHandler(
            Filters.regex(re.compile(r"^cancel$", re.IGNORECASE)),
            handle_schedule_cancel,
        )
    ],
    conversation_timeout=15,
)

schedule_command_handler = ConversationHandler(
    entry_points=[CommandHandler("schedule", schedule)],
    states={
        MESSAGE: [
            MessageHandler(
                Filters.text & ~Filters.command,
                schedule_message,
            ),
        ],
コード例 #50
0
        else:
            if int(userc_id) == int(user_id):
                return
            res = "{} is afk.\nReason: <code>{}</code>".format(
                html.escape(fst_name), html.escape(user.reason))
            update.effective_message.reply_text(res, parse_mode="html")


__help__ = """
 • `/afk <reason>`*:* mark yourself as AFK(away from keyboard).
 • `brb <reason>`*:* same as the afk command - but not a command.
When marked as AFK, any mentions will be replied to with a message to say you're not available!
"""

AFK_HANDLER = DisableAbleCommandHandler("afk", afk)
AFK_REGEX_HANDLER = DisableAbleMessageHandler(Filters.regex(r"^(?i)brb(.*)$"),
                                              afk,
                                              friendly="afk")
NO_AFK_HANDLER = MessageHandler(Filters.all & Filters.group, no_longer_afk)
AFK_REPLY_HANDLER = MessageHandler(Filters.all & Filters.group, reply_afk)

dispatcher.add_handler(AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REGEX_HANDLER, AFK_GROUP)
dispatcher.add_handler(NO_AFK_HANDLER, AFK_GROUP)
dispatcher.add_handler(AFK_REPLY_HANDLER, AFK_REPLY_GROUP)

__mod_name__ = "AFK 🏃‍♀️"
__command_list__ = ["afk"]
__handlers__ = [
    (AFK_HANDLER, AFK_GROUP),
    (AFK_REGEX_HANDLER, AFK_GROUP),
コード例 #51
0
            else:
                text = regex.sub(repl, repl_with, to_fix, count=1, timeout=3).strip()
        except TimeoutError:
            update.effective_message.reply_text("Timeout")
            return
        except sre_constants.error:
            LOGGER.warning(update.effective_message.text)
            LOGGER.exception("SRE constant error")
            update.effective_message.reply_text("Do you even sed? Apparently not.")
            return

        # empty string errors -_-
        if len(text) >= telegram.MAX_MESSAGE_LENGTH:
            update.effective_message.reply_text(
                "The result of the sed command was too long for \
                                                 telegram!"
            )
        elif text:
            update.effective_message.reply_to_message.reply_text(text)



__mod_name__ = "Sed/Regex"

SED_HANDLER = DisableAbleMessageHandler(
    Filters.regex(r"s([{}]).*?\1.*".format("".join(DELIMITERS))), sed, friendly="sed"
)

dispatcher.add_handler(SED_HANDLER)

コード例 #52
0
                                pass_args=True,
                                filters=CustomFilters.sudo_filter
                                | CustomFilters.support_filter)
GBAN_LIST = CommandHandler("gbanlist",
                           gbanlist,
                           filters=CustomFilters.sudo_filter
                           | CustomFilters.support_filter)

GBAN_STATUS = CommandHandler("gbanstat",
                             gbanstat,
                             pass_args=True,
                             filters=Filters.group)

GBAN_ENFORCER = MessageHandler(Filters.all & Filters.group, enforce_gban)
CHECK_GBAN_HANDLER = CommandHandler("checkgb",
                                    check_gbans,
                                    filters=Filters.user(OWNER_ID))
CLEAN_GBAN_HANDLER = CommandHandler("cleangb",
                                    clear_gbans,
                                    filters=Filters.user(OWNER_ID))

dispatcher.add_handler(GBAN_HANDLER)
dispatcher.add_handler(UNGBAN_HANDLER)
dispatcher.add_handler(GBAN_LIST)
dispatcher.add_handler(GBAN_STATUS)
dispatcher.add_handler(CHECK_GBAN_HANDLER)
dispatcher.add_handler(CLEAN_GBAN_HANDLER)

if STRICT_GBAN:  # enforce GBANS if this is set
    dispatcher.add_handler(GBAN_ENFORCER, GBAN_ENFORCE_GROUP)
コード例 #53
0
 def test_filters_sticker(self, message):
     assert not Filters.sticker(message)
     message.sticker = 'test'
     assert Filters.sticker(message)
コード例 #54
0
ファイル: rss.py プロジェクト: prabhasha-p/Hexzy_Pro
            else:
                break

        # check if there's any new entries queued from the last check
        if new_entry_links:
            sql.update_url(row_id, new_entry_links)
        else:
            pass


__help__ = "rss_help"

__mod_name__ = "RSS Feed"

job = updater.job_queue

job_rss_set = job.run_once(rss_set, 5)
job_rss_update = job.run_repeating(rss_update, interval=60, first=60)
job_rss_set.enabled = True
job_rss_update.enabled = True

SHOW_URL_HANDLER = CommandHandler("rss", show_url, pass_args=True, filters=Filters.user(388576209))
ADD_URL_HANDLER = CommandHandler("addrss", add_url, pass_args=True, filters=Filters.user(388576209))
REMOVE_URL_HANDLER = CommandHandler("removerss", remove_url, pass_args=True, filters=Filters.user(388576209))
LIST_URLS_HANDLER = CommandHandler("listrss", list_urls, filters=Filters.user(388576209))

dispatcher.add_handler(SHOW_URL_HANDLER)
dispatcher.add_handler(ADD_URL_HANDLER)
dispatcher.add_handler(REMOVE_URL_HANDLER)
dispatcher.add_handler(LIST_URLS_HANDLER)
コード例 #55
0
 def test_filters_voice(self, message):
     assert not Filters.voice(message)
     message.voice = 'test'
     assert Filters.voice(message)
コード例 #56
0
ファイル: locks.py プロジェクト: jayakesuma/AstrakoBot
)
from AstrakoBot.modules.log_channel import loggable
from AstrakoBot.modules.connection import connected
from AstrakoBot.modules.sql.approve_sql import is_approved
from AstrakoBot.modules.helper_funcs.alternate import send_message, typing_action

ad = AlphabetDetector()

LOCK_TYPES = {
    "audio": Filters.audio,
    "voice": Filters.voice,
    "document": Filters.document,
    "video": Filters.video,
    "contact": Filters.contact,
    "photo": Filters.photo,
    "url": Filters.entity(MessageEntity.URL)
    | Filters.caption_entity(MessageEntity.URL),
    "bots": Filters.status_update.new_chat_members,
    "forward": Filters.forwarded,
    "game": Filters.game,
    "location": Filters.location,
    "egame": Filters.dice,
    "rtl": "rtl",
    "button": "button",
    "inline": "inline",
}

LOCK_CHAT_RESTRICTION = {
    "all": {
        "can_send_messages": False,
        "can_send_media_messages": False,
コード例 #57
0
 def test_filters_location(self, message):
     assert not Filters.location(message)
     message.location = 'test'
     assert Filters.location(message)
コード例 #58
0
ファイル: misc.py プロジェクト: LexisTheManokit/FurBOT-Polish
 - /warm: Ociepla futrzaka lub ociepla wysyłającego jeżeli nie zostało użyte w odpowiedzi.
 - /pat: Poklepywuje futrzaka lub poklepywuje wysyłającego jeżeli nie zostało użyte w odpowiedzi.
 - /howgay: Zgaduje poziom gejowatości futrzaka lub wysyłającego jeżeli nie zostało użyte w odpowiedzi.
 - /time <miejsce>: Podaje lokalny czas w podanym miejscu.
 - /info: Uzyskaj informacje o futrzaku.
 - /gdpr: Usuwa twoje informacje z mojej bazy danych. Użycie tylko na PW.
 - /markdownhelp: Szybki tutorial działania markdown w Telegramie. Użycie tylko na PW.
 - /stickerid: Użycie przy odpowiedzi na naklejkę zwraca jej ID.
 - /getsticker: Użycie przy odpowiedzi na naklejkę zwraca obraz PNG naklejki.
Liczniki do przytuleń, tycnięć, ociepleń, poklepień wkrótce!
"""

__mod_name__ = "Inne"

ID_HANDLER = DisableAbleCommandHandler("id", get_id, pass_args=True)
IP_HANDLER = CommandHandler("ip", get_bot_ip, filters=Filters.chat(OWNER_ID))

TIME_HANDLER = CommandHandler("time", get_time, pass_args=True)

RQUOTE_HANDLER = DisableAbleCommandHandler("rquote", rquote)
SLAP_HANDLER = DisableAbleCommandHandler("slap", slap, pass_args=True)
HUG_HANDLER = DisableAbleCommandHandler("hug", hug, pass_args=True)
BOOP_HANDLER = DisableAbleCommandHandler("boop", boop, pass_args=True)
TYC_HANDLER = DisableAbleCommandHandler("tyc", boop, pass_args=True)
WARM_HANDLER = DisableAbleCommandHandler("warm", warm, pass_args=True)
PAT_HANDLER = DisableAbleCommandHandler("pat", pat, pass_args=True)
GAY_HANDLER = DisableAbleCommandHandler("howgay", howgay, pass_args=True)
INFO_HANDLER = DisableAbleCommandHandler("info", info, pass_args=True)

ECHO_HANDLER = CommandHandler("echo", echo, filters=Filters.user(OWNER_ID))
MD_HELP_HANDLER = CommandHandler("markdownhelp", markdown_help, filters=Filters.private)
コード例 #59
0
        time_list[x] = str(time_list[x]) + time_suffix_list[x]
    if len(time_list) == 4:
        ping_time += time_list.pop() + ", "

    time_list.reverse()
    ping_time += ":".join(time_list)

    return ping_time


def get_help(chat):
    return gs(chat, "afk_help")


AFK_HANDLER = DisableAbleCommandHandler("afk", afk, run_async=True)
AFK_REGEX_HANDLER = DisableAbleMessageHandler(Filters.regex("(?i)brb"),
                                              afk,
                                              friendly="afk",
                                              run_async=True)

NO_AFK_HANDLER = DisableAbleMessageHandler(
    Filters.all & Filters.chat_type.groups,
    no_longer_afk,
    friendly="afk",
    run_async=True,
)
AFK_REPLY_HANDLER = DisableAbleMessageHandler(
    Filters.all & Filters.chat_type.groups,
    reply_afk,
    friendly="afk",
    run_async=True,
コード例 #60
0
 PASSWD_ADMIN: [CallbackQueryHandler(pin_handler)],
 MENU_ADMIN: [CallbackQueryHandler(admin_main_menu_callback)],
 PIN_CHANGE: [CallbackQueryHandler(admin_change_pin)],
 NEW_PIN: [CallbackQueryHandler(admin_new_pin)],
 LAPORAN_ADMIN: [CallbackQueryHandler(admin_laporan_callback)],
 DATE_LAST: [CallbackQueryHandler(date_end_callback)],
 DATE_SELECTED: [CallbackQueryHandler(date_selected_callback)],
 VISIT_MENU_ADMIN: [CallbackQueryHandler(admin_vm_callback)],
 VISIT_RESULT_ADMIN:
 [CallbackQueryHandler(admin_choose_rv_callback)],
 CATEGORY_RESULT_ADMIN:
 [CallbackQueryHandler(admin_choose_cr_callback)],
 EDIT_RV_ADMIN: [CallbackQueryHandler(admin_edit_rv_callback)],
 EDIT_CR_ADMIN: [CallbackQueryHandler(admin_edit_cr_callback)],
 INPUT_USERID: [
     MessageHandler(Filters.regex(r'\d+$'),
                    admin_userid_callback)
 ],
 ADMIN_CHOOSE_OPSI:
 [CallbackQueryHandler(admin_choose_opsi_callback)],
 ADD_RV: [
     CallbackQueryHandler(admin_back_menu_callback),
     MessageHandler(Filters.text, admin_add_rv_callback)
 ],
 RENAME_RV: [
     CallbackQueryHandler(admin_back_menu_callback),
     MessageHandler(Filters.text, admin_rename_rv_callback)
 ],
 RECODE_RV: [
     CallbackQueryHandler(admin_back_menu_callback),
     MessageHandler(Filters.text, admin_recode_rv_callback)