mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-01-19 08:41:06 -06:00
Implemented user actions (needs testing)
This commit is contained in:
parent
db13c96baa
commit
85fe94ec0c
@ -1,12 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
|
||||||
from builtins import object
|
|
||||||
import re
|
|
||||||
import widgetUtils
|
import widgetUtils
|
||||||
import output
|
import output
|
||||||
from wxUI.dialogs import userActions
|
from wxUI.dialogs import userActions
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
from twython import TwythonError
|
from tweepy.error import TweepError
|
||||||
from extra import autocompletionUsers
|
from extra import autocompletionUsers
|
||||||
|
|
||||||
class userActionsController(object):
|
class userActionsController(object):
|
||||||
@ -32,51 +29,51 @@ class userActionsController(object):
|
|||||||
def follow(self, user):
|
def follow(self, user):
|
||||||
try:
|
try:
|
||||||
self.session.twitter.create_friendship(screen_name=user )
|
self.session.twitter.create_friendship(screen_name=user )
|
||||||
except TwythonError as err:
|
except TweepError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.api_code, err.reason), True)
|
||||||
|
|
||||||
def unfollow(self, user):
|
def unfollow(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.destroy_friendship(screen_name=user )
|
id = self.session.twitter.destroy_friendship(screen_name=user )
|
||||||
except TwythonError as err:
|
except TweepError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.api_code, err.reason), True)
|
||||||
|
|
||||||
def mute(self, user):
|
def mute(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.create_mute(screen_name=user )
|
id = self.session.twitter.create_mute(screen_name=user )
|
||||||
except TwythonError as err:
|
except TweepError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.api_code, err.reason), True)
|
||||||
|
|
||||||
def unmute(self, user):
|
def unmute(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.destroy_mute(screen_name=user )
|
id = self.session.twitter.destroy_mute(screen_name=user )
|
||||||
except TwythonError as err:
|
except TweepError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.api_code, err.reason), True)
|
||||||
|
|
||||||
def report(self, user):
|
def report(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.report_spam(screen_name=user )
|
id = self.session.twitter.report_spam(screen_name=user )
|
||||||
except TwythonError as err:
|
except TweepError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.api_code, err.reason), True)
|
||||||
|
|
||||||
def block(self, user):
|
def block(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.create_block(screen_name=user )
|
id = self.session.twitter.create_block(screen_name=user )
|
||||||
except TwythonError as err:
|
except TweepError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.api_code, err.reason), True)
|
||||||
|
|
||||||
def unblock(self, user):
|
def unblock(self, user):
|
||||||
try:
|
try:
|
||||||
id = self.session.twitter.destroy_block(screen_name=user )
|
id = self.session.twitter.destroy_block(screen_name=user )
|
||||||
except TwythonError as err:
|
except TweepError as err:
|
||||||
output.speak("Error %s: %s" % (err.error_code, err.msg), True)
|
output.speak("Error %s: %s" % (err.api_code, err.reason), True)
|
||||||
|
|
||||||
def ignore_client(self, user):
|
def ignore_client(self, user):
|
||||||
tweet = self.buffer.get_right_tweet()
|
tweet = self.buffer.get_right_tweet()
|
||||||
if "sender" in tweet:
|
if hasattr(tweet, "sender"):
|
||||||
output.speak(_(u"You can't ignore direct messages"))
|
output.speak(_(u"You can't ignore direct messages"))
|
||||||
return
|
return
|
||||||
client = re.sub(r"(?s)<.*?>", "", tweet["source"])
|
client = tweet.source
|
||||||
if client not in self.session.settings["twitter"]["ignored_clients"]:
|
if client not in self.session.settings["twitter"]["ignored_clients"]:
|
||||||
self.session.settings["twitter"]["ignored_clients"].append(client)
|
self.session.settings["twitter"]["ignored_clients"].append(client)
|
||||||
self.session.settings.write()
|
self.session.settings.write()
|
Loading…
x
Reference in New Issue
Block a user