mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 11:18:08 -06:00
Improvements in the tweet and dm dialogue
This commit is contained in:
parent
be9ede43a3
commit
a3e7effb83
@ -35,6 +35,7 @@ class basicTweet(object):
|
||||
t.to_lang = dest
|
||||
msg = t.translate(text_to_translate)
|
||||
self.message.set_text(msg)
|
||||
self.message.text_focus()
|
||||
output.speak(_(u"Translated"))
|
||||
else:
|
||||
return
|
||||
@ -43,29 +44,35 @@ class basicTweet(object):
|
||||
urls = utils.find_urls_in_text(self.message.get_text())
|
||||
if len(urls) == 0:
|
||||
output.speak(_(u"There's no URL to be shortened"))
|
||||
self.message.text_focus()
|
||||
elif len(urls) == 1:
|
||||
self.message.set_text(self.message.get_text().replace(urls[0], url_shortener.shorten(urls[0])))
|
||||
output.speak(_(u"URL shortened"))
|
||||
self.message.text_focus()
|
||||
elif len(urls) > 1:
|
||||
list_urls = urlList.urlList()
|
||||
list_urls.populate_list(urls)
|
||||
if list_urls.get_response() == widgetUtils.OK:
|
||||
self.message.set_text(self.message.get_text().replace(urls[list_urls.get_item()], url_shortener.shorten(list_urls.get_string())))
|
||||
output.speak(_(u"URL shortened"))
|
||||
self.message.text_focus()
|
||||
|
||||
def unshorten(self, event=None):
|
||||
urls = utils.find_urls_in_text(self.message.get_text())
|
||||
if len(urls) == 0:
|
||||
output.speak(_(u"There's no URL to be sexpanded"))
|
||||
self.message.text_focus()
|
||||
elif len(urls) == 1:
|
||||
self.message.set_text(self.message.get_text().replace(urls[0], url_shortener.unshorten(urls[0])))
|
||||
output.speak(_(u"URL expanded"))
|
||||
self.message.text_focus()
|
||||
elif len(urls) > 1:
|
||||
list_urls = urlList.urlList()
|
||||
list_urls.populate_list(urls)
|
||||
if list_urls.get_response() == widgetUtils.OK:
|
||||
self.message.set_text(self.message.get_text().replace(urls[list_urls.get_item()], url_shortener.unshorten(list_urls.get_string())))
|
||||
output.speak(_(u"URL expanded"))
|
||||
self.message.text_focus()
|
||||
|
||||
def text_processor(self, *args, **kwargs):
|
||||
self.message.set_title(_(u"%s - %s of 140 characters") % (self.title, len(self.message.get_text())))
|
||||
@ -121,7 +128,7 @@ class reply(tweet):
|
||||
def __init__(self, session, title, caption, text, users=None):
|
||||
super(reply, self).__init__(session, title, caption, text, messageType="reply")
|
||||
self.users = users
|
||||
if self.users != None:
|
||||
if self.users != None and len(self.users) > 1:
|
||||
widgetUtils.connect_event(self.message.mentionAll, widgetUtils.BUTTON_PRESSED, self.mention_all)
|
||||
self.message.enable_button("mentionAll")
|
||||
self.message.set_cursor_at_end()
|
||||
@ -129,6 +136,7 @@ class reply(tweet):
|
||||
def mention_all(self, *args, **kwargs):
|
||||
self.message.set_text(self.message.get_text()+self.users)
|
||||
self.message.set_cursor_at_end()
|
||||
self.message.text_focus()
|
||||
|
||||
class dm(basicTweet):
|
||||
def __init__(self, session, title, caption, text):
|
||||
|
Loading…
Reference in New Issue
Block a user