mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-02-21 09:03:09 -05:00
Ignoring clients improvements: adding clients from the action users dialog does always work, no matters the buffer the client is added
This commit is contained in:
parent
2ce59cf208
commit
b232a0b0ad
@ -186,18 +186,21 @@ class basePanel(wx.Panel):
|
|||||||
except TwythonError as e:
|
except TwythonError as e:
|
||||||
output.speak(e.message)
|
output.speak(e.message)
|
||||||
for i in items:
|
for i in items:
|
||||||
if config.main["general"]["reverse_timelines"] == False:
|
if twitter.utils.is_allowed(i) == True:
|
||||||
self.db.settings[self.name_buffer].insert(0, i)
|
if config.main["general"]["reverse_timelines"] == False:
|
||||||
else:
|
self.db.settings[self.name_buffer].insert(0, i)
|
||||||
self.db.settings[self.name_buffer].append(i)
|
else:
|
||||||
|
self.db.settings[self.name_buffer].append(i)
|
||||||
if config.main["general"]["reverse_timelines"] == False:
|
if config.main["general"]["reverse_timelines"] == False:
|
||||||
for i in items:
|
for i in items:
|
||||||
tweet = self.compose_function(i, self.db)
|
if twitter.utils.is_allowed(i) == True:
|
||||||
self.list.insert_item(True, *tweet)
|
tweet = self.compose_function(i, self.db)
|
||||||
|
self.list.insert_item(True, *tweet)
|
||||||
else:
|
else:
|
||||||
for i in items:
|
for i in items:
|
||||||
tweet = self.compose_function(i, self.db)
|
if twitter.utils.is_allowed(i) == True:
|
||||||
self.list.insert_item(False, *tweet)
|
tweet = self.compose_function(i, self.db)
|
||||||
|
self.list.insert_item(False, *tweet)
|
||||||
output.speak(_(u"%s items retrieved") % (len(items)))
|
output.speak(_(u"%s items retrieved") % (len(items)))
|
||||||
|
|
||||||
def put_items(self, num):
|
def put_items(self, num):
|
||||||
@ -205,7 +208,7 @@ class basePanel(wx.Panel):
|
|||||||
for i in self.db.settings[self.name_buffer]:
|
for i in self.db.settings[self.name_buffer]:
|
||||||
tweet = self.compose_function(i, self.db)
|
tweet = self.compose_function(i, self.db)
|
||||||
self.list.insert_item(False, *tweet)
|
self.list.insert_item(False, *tweet)
|
||||||
self.set_list_position()
|
self.set_list_position()
|
||||||
elif self.list.get_count() > 0:
|
elif self.list.get_count() > 0:
|
||||||
if config.main["general"]["reverse_timelines"] == False:
|
if config.main["general"]["reverse_timelines"] == False:
|
||||||
for i in self.db.settings[self.name_buffer][:num]:
|
for i in self.db.settings[self.name_buffer][:num]:
|
||||||
|
@ -23,6 +23,7 @@ import twitter
|
|||||||
from twitter import utils
|
from twitter import utils
|
||||||
from twython import TwythonError
|
from twython import TwythonError
|
||||||
import output
|
import output
|
||||||
|
import re
|
||||||
|
|
||||||
class follow(wx.Dialog):
|
class follow(wx.Dialog):
|
||||||
def __init__(self, parent, default="follow"):
|
def __init__(self, parent, default="follow"):
|
||||||
@ -48,6 +49,7 @@ class follow(wx.Dialog):
|
|||||||
self.block = wx.RadioButton(panel, -1, _(u"Block"))
|
self.block = wx.RadioButton(panel, -1, _(u"Block"))
|
||||||
self.unblock = wx.RadioButton(panel, -1, _(u"Unblock"))
|
self.unblock = wx.RadioButton(panel, -1, _(u"Unblock"))
|
||||||
self.reportSpam = wx.RadioButton(panel, -1, _(u"Report as spam"))
|
self.reportSpam = wx.RadioButton(panel, -1, _(u"Report as spam"))
|
||||||
|
self.ignore_client = wx.RadioButton(panel, -1, _(u"Ignore tweets from this client"))
|
||||||
self.setup_default(default)
|
self.setup_default(default)
|
||||||
actionSizer.Add(label2)
|
actionSizer.Add(label2)
|
||||||
actionSizer.Add(self.follow)
|
actionSizer.Add(self.follow)
|
||||||
@ -57,6 +59,7 @@ class follow(wx.Dialog):
|
|||||||
actionSizer.Add(self.block)
|
actionSizer.Add(self.block)
|
||||||
actionSizer.Add(self.unblock)
|
actionSizer.Add(self.unblock)
|
||||||
actionSizer.Add(self.reportSpam)
|
actionSizer.Add(self.reportSpam)
|
||||||
|
actionSizer.Add(self.ignore_client)
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
|
ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
|
||||||
ok.Bind(wx.EVT_BUTTON, self.onok)
|
ok.Bind(wx.EVT_BUTTON, self.onok)
|
||||||
@ -133,6 +136,15 @@ class follow(wx.Dialog):
|
|||||||
self.Destroy()
|
self.Destroy()
|
||||||
except TwythonError as err:
|
except TwythonError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
||||||
|
elif self.ignore_client.GetValue() == True:
|
||||||
|
tweet = self.parent.get_tweet()
|
||||||
|
if tweet.has_key("sender"):
|
||||||
|
output.speak(_(u"You can't ignore direct messages"))
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
client = re.sub(r"(?s)<.*?>", "", tweet["source"])
|
||||||
|
if client not in config.main["twitter"]["ignored_clients"]:
|
||||||
|
config.main["twitter"]["ignored_clients"].append(client)
|
||||||
|
|
||||||
def setup_default(self, default):
|
def setup_default(self, default):
|
||||||
if default == "follow":
|
if default == "follow":
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from twitter import compose
|
from twitter import compose, utils
|
||||||
from twython import TwythonStreamer
|
from twython import TwythonStreamer
|
||||||
import sound
|
import sound
|
||||||
from mysc import event
|
from mysc import event
|
||||||
@ -44,7 +44,7 @@ class streamer(TwythonStreamer):
|
|||||||
|
|
||||||
def on_success(self, data):
|
def on_success(self, data):
|
||||||
try:
|
try:
|
||||||
if data.has_key("text"):
|
if data.has_key("text") and utils.is_allowed(data):
|
||||||
self.check_tls(data)
|
self.check_tls(data)
|
||||||
elif "friends" in data:
|
elif "friends" in data:
|
||||||
self.friends = data["friends"]
|
self.friends = data["friends"]
|
||||||
|
@ -153,7 +153,7 @@ def compose_tweet(tweet, db):
|
|||||||
else: user = tweet["sender"]["name"]
|
else: user = tweet["sender"]["name"]
|
||||||
elif tweet.has_key("user"):
|
elif tweet.has_key("user"):
|
||||||
user = tweet["user"]["name"]
|
user = tweet["user"]["name"]
|
||||||
source = re.sub(r"(?s)<.*?>", " ", tweet["source"])
|
source = re.sub(r"(?s)<.*?>", "", tweet["source"])
|
||||||
try: text = "rt @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], StripChars(tweet["retweeted_status"]["text"]))
|
try: text = "rt @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], StripChars(tweet["retweeted_status"]["text"]))
|
||||||
except KeyError: text = "%s" % (StripChars(tweet["text"]))
|
except KeyError: text = "%s" % (StripChars(tweet["text"]))
|
||||||
if text[-1] in chars: text=text+"."
|
if text[-1] in chars: text=text+"."
|
||||||
|
@ -75,15 +75,16 @@ def start_stream(db, twitter, name, function, param=None):
|
|||||||
last_id = 0
|
last_id = 0
|
||||||
if len(db.settings[name]) > 0:
|
if len(db.settings[name]) > 0:
|
||||||
for i in tl:
|
for i in tl:
|
||||||
if int(i["id"]) > int(last_id):
|
if int(i["id"]) > int(last_id) and utils.is_allowed(i) == True:
|
||||||
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
||||||
else: db.settings[name].insert(0, i)
|
else: db.settings[name].insert(0, i)
|
||||||
num = num+1
|
num = num+1
|
||||||
elif len(db.settings[name]) == 0:
|
elif len(db.settings[name]) == 0:
|
||||||
for i in tl:
|
for i in tl:
|
||||||
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
if utils.is_allowed(i) == True:
|
||||||
else: db.settings[name].insert(0, i)
|
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
||||||
num = num+1
|
else: db.settings[name].insert(0, i)
|
||||||
|
num = num+1
|
||||||
# db.settings.update()
|
# db.settings.update()
|
||||||
return num
|
return num
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ def update_stream(config, twitter, name, function, param=None, sndFile=""):
|
|||||||
tl = function(sinze_id=config.settings[name][-1]["id"], screen_name=param, count=config.main["general"]["max_tweets_per_call"])
|
tl = function(sinze_id=config.settings[name][-1]["id"], screen_name=param, count=config.main["general"]["max_tweets_per_call"])
|
||||||
tl.reverse()
|
tl.reverse()
|
||||||
for i in tl:
|
for i in tl:
|
||||||
if i["id"] > config.settings[name][-1]["id"]:
|
if i["id"] > config.settings[name][-1]["id"] and utils.is_allowed(i) == True:
|
||||||
config.settings[name].append(i)
|
config.settings[name].append(i)
|
||||||
sounded = True
|
sounded = True
|
||||||
num = num+1
|
num = num+1
|
||||||
@ -189,15 +190,16 @@ def start_list(db, twitter, name, list_id, *args, **kwargs):
|
|||||||
last_id = 0
|
last_id = 0
|
||||||
if len(db.settings[name]) > 0:
|
if len(db.settings[name]) > 0:
|
||||||
for i in tl:
|
for i in tl:
|
||||||
if int(i["id"]) > int(last_id):
|
if int(i["id"]) > int(last_id) and utils.is_allowed(i) == True:
|
||||||
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
||||||
else: db.settings[name].insert(0, i)
|
else: db.settings[name].insert(0, i)
|
||||||
num = num+1
|
num = num+1
|
||||||
elif len(db.settings[name]) == 0:
|
elif len(db.settings[name]) == 0:
|
||||||
for i in tl:
|
for i in tl:
|
||||||
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
if utils.is_allowed(i) == True:
|
||||||
else: db.settings[name].insert(0, i)
|
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
||||||
num = num+1
|
else: db.settings[name].insert(0, i)
|
||||||
|
num = num+1
|
||||||
db.settings.update()
|
db.settings.update()
|
||||||
return num
|
return num
|
||||||
|
|
||||||
@ -209,15 +211,16 @@ def search(db, twitter, name, *args, **kwargs):
|
|||||||
tl["statuses"].reverse()
|
tl["statuses"].reverse()
|
||||||
if len(db.settings[name]) > 0:
|
if len(db.settings[name]) > 0:
|
||||||
for i in tl["statuses"]:
|
for i in tl["statuses"]:
|
||||||
if utils.find_item(i["id"], db.settings[name]) == None:
|
if utils.find_item(i["id"], db.settings[name]) == None and utils.is_allowed(i):
|
||||||
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
||||||
else: db.settings[name].insert(0, i)
|
else: db.settings[name].insert(0, i)
|
||||||
num = num+1
|
num = num+1
|
||||||
elif len(db.settings[name]) == 0:
|
elif len(db.settings[name]) == 0:
|
||||||
for i in tl["statuses"]:
|
for i in tl["statuses"]:
|
||||||
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
if utils.is_allowed(i) == True:
|
||||||
else: db.settings[name].insert(0, i)
|
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
||||||
num = num+1
|
else: db.settings[name].insert(0, i)
|
||||||
|
num = num+1
|
||||||
return num
|
return num
|
||||||
|
|
||||||
def search_users(db, twitter, name, *args, **kwargs):
|
def search_users(db, twitter, name, *args, **kwargs):
|
||||||
@ -247,13 +250,14 @@ def get_favourites_timeline(db, twitter, name, param, *args, **kwargs):
|
|||||||
tl.reverse()
|
tl.reverse()
|
||||||
if len(db.settings[name]) > 0:
|
if len(db.settings[name]) > 0:
|
||||||
for i in tl:
|
for i in tl:
|
||||||
if utils.find_item(i["id"], db.settings[name]) == None:
|
if utils.find_item(i["id"], db.settings[name]) == None and utils.is_allowed(i) == True:
|
||||||
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
||||||
else: db.settings[name].insert(0, i)
|
else: db.settings[name].insert(0, i)
|
||||||
num = num+1
|
num = num+1
|
||||||
elif len(db.settings[name]) == 0:
|
elif len(db.settings[name]) == 0:
|
||||||
for i in tl:
|
for i in tl:
|
||||||
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
if utils.is_allowed(i) == True:
|
||||||
else: db.settings[name].insert(0, i)
|
if config.main["general"]["reverse_timelines"] == False: db.settings[name].append(i)
|
||||||
num = num+1
|
else: db.settings[name].insert(0, i)
|
||||||
|
num = num+1
|
||||||
return num
|
return num
|
@ -109,9 +109,12 @@ def api_call(parent=None, call_name=None, preexec_message="", success="", succes
|
|||||||
return val
|
return val
|
||||||
|
|
||||||
def is_allowed(tweet):
|
def is_allowed(tweet):
|
||||||
allowed = True
|
try:
|
||||||
if tweet.has_key("retweeted_status"): tweet = tweet["retweeted_status"]
|
allowed = True
|
||||||
source = re.sub(r"(?s)<.*?>", "", tweet["source"])
|
if tweet.has_key("retweeted_status"): tweet = tweet["retweeted_status"]
|
||||||
for i in config.main["twitter"]["ignored_clients"]:
|
source = re.sub(r"(?s)<.*?>", "", tweet["source"])
|
||||||
if i.lower() == source.lower(): allowed = False
|
for i in config.main["twitter"]["ignored_clients"]:
|
||||||
return allowed
|
if i.lower() == source.lower(): allowed = False
|
||||||
|
return allowed
|
||||||
|
except KeyError:
|
||||||
|
return True
|
Loading…
x
Reference in New Issue
Block a user