Exemplo n.º 1
0
def main():
    # Creating new bot instance.
    bot = ICQBot(token=TOKEN, name=NAME, version=VERSION)

    # Registering required handlers for messages.
    bot.dispatcher.add_handler(CommandHandler(callback=command_callback))
    bot.dispatcher.add_handler(
        UserAddedToBuddyListHandler(callback=user_added_callback))
    bot.dispatcher.add_handler(
        MessageHandler(callback=text_callback, filters=MessageFilter.text))
    bot.dispatcher.add_handler(
        MessageHandler(callback=sticker_callback,
                       filters=MessageFilter.sticker))
    bot.dispatcher.add_handler(
        MessageHandler(callback=link_callback, filters=MessageFilter.link))
    bot.dispatcher.add_handler(
        MessageHandler(callback=image_callback, filters=MessageFilter.image))
    bot.dispatcher.add_handler(
        MessageHandler(callback=video_callback, filters=MessageFilter.video))
    bot.dispatcher.add_handler(
        MessageHandler(callback=audio_callback, filters=MessageFilter.audio))
    bot.dispatcher.add_handler(
        MessageHandler(callback=chat_callback, filters=MessageFilter.chat))

    bot.dispatcher.add_handler(
        FeedbackCommandHandler(command="fb", target="176756440"))

    # Starting polling thread watching for new events from server. This is non-blocking call.
    bot.start_polling()

    # Block current thread while bot working until SIGINT, SIGTERM or SIGABRT received.
    bot.idle()
Exemplo n.º 2
0
def main():
    # Creating a new bot instance.
    bot = ICQBot(token=TOKEN, name=NAME, version=VERSION)

    # Registering handlers.
    bot.dispatcher.add_handler(UserAddedToBuddyListHandler(help_cb))
    bot.dispatcher.add_handler(MessageHandler(filters=MessageFilter.text, callback=search_cb))
    bot.dispatcher.add_handler(CommandHandler(command="random", callback=random_cb))
    bot.dispatcher.add_handler(CommandHandler(command="trending", callback=trending_cb))
    bot.dispatcher.add_handler(FeedbackCommandHandler(target=OWNER, reply="Got it!\n---\nПринято!"))
    bot.dispatcher.add_handler(UnknownCommandHandler(callback=help_cb))
    bot.dispatcher.add_handler(MessageHandler(
        filters=MessageFilter.message & ~(MessageFilter.text | MessageFilter.command), callback=help_cb
    ))

    # Starting a polling thread watching for new events from server. This is a non-blocking call.
    bot.start_polling()

    # Blocking the current thread while the bot is working until SIGINT, SIGTERM or SIGABRT is received.
    bot.idle()
Exemplo n.º 3
0
def main():
    # Creating a new bot instance.
    bot = ICQBot(token=TOKEN, name=NAME, version=VERSION)

    # Registering message handlers.
    bot.dispatcher.add_handler(TypingHandler(typing_callback))
    bot.dispatcher.add_handler(
        MessageHandler(callback=message_callback,
                       filters=MessageFilter.text | MessageFilter.sticker))

    # Registering command handlers.
    bot.dispatcher.add_handler(
        CommandHandler(callback=help_callback, command="help"))
    bot.dispatcher.add_handler(
        CommandHandler(callback=status_callback, command="status"))
    bot.dispatcher.add_handler(FeedbackCommandHandler(target=OWNER))
    bot.dispatcher.add_handler(UnknownCommandHandler(message_callback))

    # Starting a polling thread watching for new events from server. This is a non-blocking call.
    bot.start_polling()

    # Blocking the current thread while the bot is working until SIGINT, SIGTERM or SIGABRT is received.
    bot.idle()
Exemplo n.º 4
0
def main():
    # Creating new bot instance.
    bot = ICQBot(token=TOKEN, name=NAME, version=VERSION)

    # Registering required handlers for messages.
    bot.dispatcher.add_handler(
        MessageHandler(callback=message_callback,
                       filters=MessageFilter.text | MessageFilter.sticker))

    # Registering command handlers.
    bot.dispatcher.add_handler(
        CommandHandler(callback=help_callback, command="help"))
    bot.dispatcher.add_handler(UnknownCommandHandler(message_callback))

    # Starting polling thread watching for new events from server. This is non-blocking call.
    bot.start_polling()

    # Block current thread while bot working until SIGINT, SIGTERM or SIGABRT received.
    bot.idle()
Exemplo n.º 5
0
def main():
    # Creating a new bot instance.
    bot = ICQBot(token=TOKEN, name=NAME, version=VERSION)

    # Registering message handlers.
    bot.dispatcher.add_handler(
        CommandHandler(callback=help_command_callback, command="help"))
    bot.dispatcher.add_handler(
        UnknownCommandHandler(callback=unknown_command_callback))
    bot.dispatcher.add_handler(
        UserAddedToBuddyListHandler(callback=user_added_callback))
    bot.dispatcher.add_handler(TypingHandler(callback=typing_callback))
    bot.dispatcher.add_handler(
        MessageHandler(callback=text_callback, filters=MessageFilter.text))
    bot.dispatcher.add_handler(
        MessageHandler(callback=sticker_callback,
                       filters=MessageFilter.sticker))
    bot.dispatcher.add_handler(
        MessageHandler(callback=url_callback, filters=MessageFilter.url))
    bot.dispatcher.add_handler(
        MessageHandler(callback=image_callback, filters=MessageFilter.image))
    bot.dispatcher.add_handler(
        MessageHandler(callback=video_callback, filters=MessageFilter.video))
    bot.dispatcher.add_handler(
        MessageHandler(callback=audio_callback, filters=MessageFilter.audio))
    bot.dispatcher.add_handler(
        MessageHandler(callback=chat_callback, filters=MessageFilter.chat))
    bot.dispatcher.add_handler(DefaultHandler(callback=default_callback))

    # Registering command handlers.
    bot.dispatcher.add_handler(FeedbackCommandHandler(target=OWNER))

    # Starting a polling thread watching for new events from server. This is a non-blocking call.
    bot.start_polling()

    # Blocking the current thread while the bot is working until SIGINT, SIGTERM or SIGABRT is received.
    bot.idle()