mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-18 06:06:06 -04:00
Updated some translations; basic proxy support (needs testing)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import config
|
||||
from requests.auth import HTTPProxyAuth
|
||||
from twitter import compose, utils
|
||||
from twython import TwythonStreamer
|
||||
from pubsub import pub
|
||||
@@ -8,7 +10,14 @@ log = original_logger.getLogger("TimelinesStream")
|
||||
class timelinesStreamer(TwythonStreamer):
|
||||
def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret, timeout=300, retry_count=None, retry_in=10, client_args=None, handlers=None, chunk_size=1, session=None):
|
||||
self.session = session
|
||||
super(timelinesStreamer, self).__init__(app_key, app_secret, oauth_token, oauth_token_secret, timeout=60, retry_count=None, retry_in=180, client_args=None, handlers=None, chunk_size=1)
|
||||
args = None
|
||||
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
|
||||
super(timelinesStreamer, self).__init__(app_key, app_secret, oauth_token, oauth_token_secret, timeout=60, retry_count=None, retry_in=180, client_args=args, handlers=None, chunk_size=1)
|
||||
|
||||
def on_error(self, status_code, data):
|
||||
log.debug("%s: %s" % (status_code, data))
|
||||
|
@@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import config
|
||||
from requests.auth import HTTPProxyAuth
|
||||
from twitter import utils
|
||||
from twython import TwythonStreamer
|
||||
from pubsub import pub
|
||||
@@ -6,8 +8,15 @@ import logging as original_logger
|
||||
log = original_logger.getLogger("MainStream")
|
||||
|
||||
class streamer(TwythonStreamer):
|
||||
def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret, sessionObject, *args, **kwargs):
|
||||
super(streamer, self).__init__(app_key, app_secret, oauth_token, oauth_token_secret, *args, **kwargs)
|
||||
def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret, sessionObject, *a, **kw):
|
||||
args = None
|
||||
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
|
||||
super(streamer, self).__init__(app_key, app_secret, oauth_token, oauth_token_secret, client_args=args, *a, **kw)
|
||||
self.session = sessionObject
|
||||
self.muted_users = self.session.db["muted_users"]
|
||||
# self.blocked_users = []
|
||||
|
@@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from requests.auth import HTTPProxyAuth
|
||||
import config
|
||||
import random
|
||||
import BaseHTTPServer
|
||||
import webbrowser
|
||||
@@ -6,11 +8,18 @@ from twython import Twython, TwythonError
|
||||
from keys import keyring
|
||||
import authorisationHandler
|
||||
|
||||
|
||||
class twitter(object):
|
||||
|
||||
def login(self, user_key, user_secret, verify_credentials):
|
||||
self.twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), user_key, user_secret)
|
||||
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()
|
||||
|
||||
@@ -18,7 +27,15 @@ class twitter(object):
|
||||
authorisationHandler.logged = False
|
||||
port = random.randint(30000, 66000)
|
||||
httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', port), authorisationHandler.handler)
|
||||
twitter = Twython(keyring.get("api_key"), keyring.get("api_secret"), auth_endpoint='authorize')
|
||||
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:
|
||||
|
Reference in New Issue
Block a user