def login(self, user_key, user_secret, verify_credentials): if config.app["proxy"]["server"] != "" and config.app["proxy"][ "port"] != "": args = { "proxies": { "http": "http://{0}:{1}".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), "https": "https://{0}:{1}".format(config.app["proxy"]["server"], config.app["proxy"]["port"]) } } if config.app["proxy"]["user"] != "" and config.app["proxy"][ "password"] != "": auth = HTTPProxyAuth(config.app["proxy"]["user"], config.app["proxy"]["password"]) args["auth"] = auth self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), user_key, user_secret, client_args=args) else: self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), user_key, user_secret) if verify_credentials == True: self.credentials = self.twitter.verify_credentials()
def login(self, user_key, user_secret, verify_credentials): if config.app["proxy"]["server"] != "" and config.app["proxy"]["port"] != "": args = {"proxies": {"http": "http://{0}:{1}".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), "https": "https://{0}:{1}".format(config.app["proxy"]["server"], config.app["proxy"]["port"])}} if config.app["proxy"]["user"] != "" and config.app["proxy"]["password"] != "": auth = HTTPProxyAuth(config.app["proxy"]["user"], config.app["proxy"]["password"]) args["auth"] = auth self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), user_key, user_secret, client_args=args) else: self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), user_key, user_secret) if verify_credentials == True: self.credentials = self.twitter.verify_credentials()
def get_timelines(self): log.debug("Starting the timelines stream...") self.timelinesStream = twitter.buffers.indibidual.timelinesStreamer(keyring.get("api_key"), keyring.get("api_secret"), self.settings["twitter"]["user_key"], self.settings["twitter"]["user_secret"], session=self) ids = "" for i in self.settings["other_buffers"]["timelines"]: ids = ids + "%s, " % (self.db[i+"-timeline"][0]["user"]["id_str"]) for i in self.lists: for z in i.users: ids += str(z) + ", " if ids != "": stream_threaded(self.timelinesStream.statuses.filter, self.session_id, follow=ids)
def get_timelines(self): log.debug("Starting the timelines stream...") self.timelinesStream = twitter.buffers.indibidual.timelinesStreamer(keyring.get("api_key"), keyring.get("api_secret"), self.settings["twitter"]["user_key"], self.settings["twitter"]["user_secret"], session=self) ids = "" for i in self.settings["other_buffers"]["timelines"]: ids = ids + "%s, " % (self.db[i+"-timeline"][0]["user"]["id_str"]) for i in self.lists: for z in i.users: ids += str(z) + ", " if ids != "": # print ids stream_threaded(self.timelinesStream.statuses.filter, self.session_id, follow=ids)
def authorise(self, settings): authorisationHandler.logged = False port = random.randint(30000, 65535) httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', port), authorisationHandler.handler) if config.app["proxy"]["server"] != "" and config.app["proxy"][ "port"] != "": args = { "proxies": { "http": "http://{0}:{1}".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), "https": "https://{0}:{1}".format(config.app["proxy"]["server"], config.app["proxy"]["port"]) } } if config.app["proxy"]["user"] != "" and config.app["proxy"][ "password"] != "": auth = HTTPProxyAuth(config.app["proxy"]["user"], config.app["proxy"]["password"]) args["auth"] = auth twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), auth_endpoint='authorize', client_args=args) else: twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), auth_endpoint='authorize') auth = twitter.get_authentication_tokens("http://127.0.0.1:{0}".format( port, )) webbrowser.open_new_tab(auth['auth_url']) while authorisationHandler.logged == False: httpd.handle_request() self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), auth['oauth_token'], auth['oauth_token_secret']) final = self.twitter.get_authorized_tokens( authorisationHandler.verifier) self.save_configuration(settings, final["oauth_token"], final["oauth_token_secret"]) httpd.server_close()
def authorise(self, settings): authorisationHandler.logged = False port = random.randint(30000, 65535) httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', port), authorisationHandler.handler) if config.app["proxy"]["server"] != "" and config.app["proxy"]["port"] != "": args = {"proxies": {"http": "http://{0}:{1}".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), "https": "https://{0}:{1}".format(config.app["proxy"]["server"], config.app["proxy"]["port"])}} if config.app["proxy"]["user"] != "" and config.app["proxy"]["password"] != "": auth = HTTPProxyAuth(config.app["proxy"]["user"], config.app["proxy"]["password"]) args["auth"] = auth twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), auth_endpoint='authorize', client_args=args) else: twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), auth_endpoint='authorize') auth = twitter.get_authentication_tokens("http://127.0.0.1:{0}".format(port,)) webbrowser.open_new_tab(auth['auth_url']) while authorisationHandler.logged == False: httpd.handle_request() self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), auth['oauth_token'], auth['oauth_token_secret']) final = self.twitter.get_authorized_tokens(authorisationHandler.verifier) self.save_configuration(settings, final["oauth_token"], final["oauth_token_secret"]) httpd.server_close()
def get_main_stream(self): log.debug("Starting the main stream...") self.main_stream = twitter.buffers.stream.streamer(keyring.get("api_key"), keyring.get("api_secret"), self.settings["twitter"]["user_key"], self.settings["twitter"]["user_secret"], self) stream_threaded(self.main_stream.user, self.session_id)