# pp.pprint(chat) # pp.pprint(what) pass @utils.delayed(default_delay) def cron_plugins(): print('yay!') def noop(): pass # Set callbacks tgl.set_on_binlog_replay_end(on_binlog_replay_end) tgl.set_on_get_difference_end(on_get_difference_end) tgl.set_on_our_id(on_our_id) tgl.set_on_msg_receive(on_msg_receive) tgl.set_on_secret_chat_update(on_secret_chat_update) tgl.set_on_user_update(on_user_update) tgl.set_on_chat_update(on_chat_update) tgl.set_on_loop(noop) # Make work the delayed functions :) # utils.import_plugins(utils.get_all_plugins(['test'])) # utils.execute_plugin_function('test', 'run', '', []) # utils.execute_plugin_function('test', 'run', '', []) # utils.execute_plugin_function('test', 'run', '', []) # utils.execute_plugin_function('test', 'run', '', []) # utils.execute_plugin_function('test', 'run', '', [])
import tgl from telex import TelexBot bot = TelexBot() # Set callbacks tgl.set_on_binlog_replay_end(bot.on_binlog_replay_end) tgl.set_on_get_difference_end(bot.on_get_difference_end) tgl.set_on_our_id(bot.on_our_id) tgl.set_on_msg_receive(bot.on_msg_receive) tgl.set_on_secret_chat_update(bot.on_secret_chat_update) tgl.set_on_user_update(bot.on_user_update) tgl.set_on_chat_update(bot.on_chat_update) tgl.set_on_loop(bot.on_loop) # TODO: Make this configurable tgl.set_link_preview(False)
pp.pprint(msg) if msg.text is not None and msg.text.startswith("!ping"): peer.send_msg("PONG! google.com", preview=False, reply=msg.id) def on_secret_chat_update(peer, types): return "on_secret_chat_update" def on_user_update(peer, what_changed): pass def on_chat_update(peer, what_changed): pass def on_loop(): pass # Set callbacks tgl.set_on_binlog_replay_end(on_binlog_replay_end) tgl.set_on_get_difference_end(on_get_difference_end) tgl.set_on_our_id(on_our_id) tgl.set_on_msg_receive(on_msg_receive) tgl.set_on_secret_chat_update(on_secret_chat_update) tgl.set_on_user_update(on_user_update) tgl.set_on_chat_update(on_chat_update) tgl.set_on_loop(on_loop)
import traceback traceback.print_exc() def on_secret_chat_update(peer, types): return "on_secret_chat_update" def on_user_update(peer, what): pass def on_chat_update(peer, what): pass def on_loop(): # processing message stored in queue while not ch.msg_result_queue.empty(): r = ch.msg_result_queue.get() if r.peer: r.peer.send_msg(r.content) else: print("Got async message but r.peer not set.") # Set callbacks tgl.set_on_binlog_replay_end(on_binlog_replay_end) tgl.set_on_get_difference_end(on_get_difference_end) tgl.set_on_our_id(on_our_id) tgl.set_on_msg_receive(on_msg_receive) tgl.set_on_secret_chat_update(on_secret_chat_update) tgl.set_on_user_update(on_user_update) tgl.set_on_chat_update(on_chat_update) tgl.set_on_loop(on_loop)