tg.msg(msg['cmdgroup'], 'By your command') QUIT = True except GeneratorExit: pass if __name__ == '__main__': # Instantiate Telegram class telegram = './telegram' pubkey = 'tg.pub' tg = pytg.Telegram(telegram, pubkey) # Create processing pipeline # Bot will respond to command the posted in this chat group grpname = 'kangkung for dummies' pipeline = message(command_parser(grpname, tg)) # Register our processing pipeline tg.register_pipeline(pipeline) # Start telegram cli tg.start() while True: # Keep on polling so that messages will pass through our pipeline tg.poll() if QUIT == True: break # Quit gracefully tg.quit()
) updateDatabase() [game, fantasyTeams] = updateDb() #fantasyTeams = updateDb() tg.msg(chat_group, "Okay, done") if Response is not None: print Response for line in Response.split('\n'): tg.msg(chat_group, line.rstrip(',')) except GeneratorExit: pass telegram = '/home/shreyas/Programs/Scraper/pytg/tg/telegram' pubkey = '/home/shreyas/Programs/Scraper/pytg/tg/tg.pub' tg = pytg.Telegram(telegram, pubkey) pipeline = message(command_parser('cwc', tg)) tg.register_pipeline(pipeline) tg.start() while True: try: tg.poll() except Exception, e: print "Exception thrown, lets deal with it" sleep(1) tg.quit()
pubkey = 'tg.pub' tg = pytg.Telegram(telegram, pubkey) # Get own id (integer represented as string datatype) myid = tg.whoami() # Variables that represents some states whether we're send some commands # to telegram has_send_contact_list = False has_send_user_info = False # Create processing pipeline # All messages will be process and finally pushed to dump_msg d = dump_msg() pipeline = broadcast([ message(d), user_status(d), dialog_list(d), chat_info(d), user_info(d), contact_list(d), service_message(d), ]) # Register our processing pipeline tg.register_pipeline(pipeline) # Start telegram cli tg.start() try: while True:
pubkey = "tg.pub" tg = pytg.Telegram(telegram, pubkey) # Get own id (integer represented as string datatype) myid = tg.whoami() # Variables that represents some states whether we're send some commands # to telegram has_send_contact_list = False has_send_user_info = False # Create processing pipeline # All messages will be process and finally pushed to dump_msg d = dump_msg() pipeline = broadcast( [message(d), user_status(d), dialog_list(d), chat_info(d), user_info(d), contact_list(d), service_message(d)] ) # Register our processing pipeline tg.register_pipeline(pipeline) # Start telegram cli tg.start() try: while True: # Keep on polling so that messages will pass through our pipeline tg.poll() if tg.ready and not has_send_contact_list: tg.contact_list() has_send_contact_list = True if tg.ready and not has_send_user_info:
if msg['uid'] == '1234567': # Put your user id here tg.msg(msg['cmdgroup'], 'By your command') QUIT = True except GeneratorExit: pass if __name__ == '__main__': # Instantiate Telegram class telegram = './telegram' pubkey = 'tg.pub' tg = pytg.Telegram(telegram, pubkey) # Create processing pipeline # Bot will respond to command the posted in this chat group grpname = 'kangkung for dummies' pipeline = message(command_parser(grpname, tg)) # Register our processing pipeline tg.register_pipeline(pipeline) # Start telegram cli tg.start() while True: # Keep on polling so that messages will pass through our pipeline tg.poll() if QUIT == True: break # Quit gracefully tg.quit()