def main(): # set up logging logger = logging.getLogger() logger.setLevel(logging.INFO) stream_handler = logging.StreamHandler(sys.stdout) stream_handler.setFormatter(logging.Formatter(KikClient.log_format())) logger.addHandler(stream_handler) # create the bot bot = EchoBot()
def on_register_error(self, response: SignUpError): if "captcha_url" in dir(response): print(response.captcha_url) result = input("Captcha result:") client.register(args.email, args.username, args.password, args.firstname, args.lastname, args.birthday, result) else: print("Unable to register! error information:\r\n{}".format(response)) def on_roster_received(self, response: FetchRosterResponse): print("Friends: {}".format(response.peers)) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('username') parser.add_argument('email') parser.add_argument('-p', '--password') parser.add_argument('--firstname', default='Not A') parser.add_argument('--lastname', default='Human') parser.add_argument('--birthday', default='01-01-1990') args = parser.parse_args() if args.password is None: args.password = input('Password: ') logging.basicConfig(format=KikClient.log_format(), level=logging.DEBUG) client = KikClient(callback=RegisterClient(), kik_username=None, kik_password=None) client.register(args.email, args.username, args.password, args.firstname, args.lastname, args.birthday)
while True: message = input() if message.startswith('/'): action = message[1] if action == 'c' and len(message) > 3: for jid in friends: if jid.startswith(message[3:]): print("Chatting with {}".format(jid_to_username(jid))) peer_jid = jid break elif action == 'f': client.request_roster() else: if peer_jid and message: client.send_chat_message(peer_jid, message) if __name__ == '__main__': # set up logging logger = logging.getLogger() logger.setLevel(logging.INFO) stream_handler = logging.StreamHandler(sys.stdout) stream_handler.setFormatter(logging.Formatter(KikClient.log_format())) logger.addHandler(stream_handler) # create the client callback = InteractiveChatClient() client = KikClient(callback=callback, kik_username=username, kik_password=password)