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()
def main(): # Creating a new bot instance. bot = ICQBot(token=TOKEN, name=NAME, version=VERSION) # Registering message handlers. bot.dispatcher.add_handler(HelpCommandHandler(callback=help_cb)) bot.dispatcher.add_handler( UnknownCommandHandler(callback=unknown_command_cb)) bot.dispatcher.add_handler(UserAddedToBuddyListHandler(user_added_cb)) bot.dispatcher.add_handler(TypingHandler(typing_cb)) bot.dispatcher.add_handler( MessageHandler(filters=MessageFilter.text, callback=text_cb)) bot.dispatcher.add_handler( MessageHandler(filters=MessageFilter.sticker, callback=sticker_cb)) bot.dispatcher.add_handler( MessageHandler(filters=MessageFilter.url, callback=url_cb)) bot.dispatcher.add_handler( MessageHandler(filters=MessageFilter.image, callback=image_cb)) bot.dispatcher.add_handler( MessageHandler(filters=MessageFilter.video, callback=video_cb)) bot.dispatcher.add_handler( MessageHandler(filters=MessageFilter.audio, callback=audio_cb)) bot.dispatcher.add_handler( MessageHandler(filters=MessageFilter.chat, callback=chat_cb)) bot.dispatcher.add_handler(DefaultHandler(default_cb)) # 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()
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(HelpCommandHandler(callback=help_cb)) bot.dispatcher.add_handler( MessageHandler(filters=~MessageFilter.command, callback=message_cb)) bot.dispatcher.add_handler(UnknownCommandHandler(callback=message_cb)) 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()
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()