def NewReply(self, buffer=None, index=None, text="", user=None): """Allows you to post a reply to a tweet.""" default = user users = buffer.get_all_screen_names(index) if 'source' not in buffer[index] and 'text' in buffer[index] and self.session.config['UI']['DMSafeMode']: return self.NewDm(buffer, index, text) if not self.session.config['UI']['replyToSelf']: for n, u in enumerate(users): if self.session.is_current_user(u): users.remove(users[n]) if default: users.insert(0, default) if not users: return output.speak(_("Unable to detect a user to reply to."), True) new = modal_dialog(gui.NewReplyDialog, parent=self.session.frame, default=users[0], selection=users, title=_("Reply"), text=text) user = new.selection.GetValue() fulltext = templates.replyTemplate(user, new.message.GetValue()) if len(fulltext) > self.session.config['lengths']['tweetLength']: i = fulltext.index(" ") + 1 return self.NewReply(buffer, index, fulltext[i:]) if new.delay: delay_action(new.delay, self.session.post_reply, buffer=buffer, index=index, text=fulltext, action=_("reply")) else: call_threaded(self.session.post_reply, buffer=buffer, index=index, text=fulltext)
def NewTweet(self, buffer=None, index=None, text=u"", title=None, retweet=False, quote=False): """Allows you to post a new tweet. """ new = gui.NewTweetDialog(parent=self.session.frame, text=text, title=title) new.retweet.Show(retweet) new.quote.Show(quote) new.message.SetInsertionPoint(0) val=new.ShowModal() if val==wx.ID_OK: if new.retweet.GetValue(): return self.Retweet(buffer, index) elif new.quote.GetValue(): return self.Quote(buffer, index) else: text = new.message.GetValue() else: logging.debug("User canceled post.") return output.speak(_("Canceled."), True) if len(text) > self.session.config['lengths']['tweetLength']: logging.info("Tweet too long. Forcing edit.") return self.NewTweet(buffer, index, text) if new.delay: delay_action(new.delay, self.session.post_update, text=text, action=_("tweet")) else: call_threaded(self.session.post_update, text=text)
def NewDm(self, buffer=None, index=None, user=u"", text=u""): """Allows you to send a new direct message to a user.""" who = buffer.get_all_screen_names(index) new = modal_dialog(gui.NewDirectDialog, parent=self.session.frame, default=who[0], selection=who, title=_("Direct message"), text=text) user = new.selection.GetValue() text = new.message.GetValue() if len(text) > self.session.config['lengths']['dmLength']: logging.info("Direct message too long. Forcing edit.") return self.NewDm(buffer, index, user, text) if new.delay: delay_action(new.delay, self.session.post_dm, text=text, buffer=buffer, index=index, user=user, action=_("dm")) else: call_threaded(self.session.post_dm, buffer=buffer, index=index, user=user, text=text)
def NewTweet(self, buffer=None, index=None, text="", title=None, retweet=False): """Allows you to post a new tweet. """ new = gui.NewTweetDialog(parent=self.session.frame, text=text, title=title) new.retweet.Show(retweet) new.message.SetInsertionPoint(0) val = new.ShowModal() if val == wx.ID_OK: if new.retweet.GetValue(): return self.Retweet(buffer, index) else: text = new.message.GetValue() else: logging.debug("User canceled post.") return output.speak(_("Canceled."), True) if len(text) > self.session.config['lengths']['tweetLength']: logging.info("Tweet too long. Forcing edit.") return self.NewTweet(buffer, index, text) if new.delay: delay_action(new.delay, self.session.post_update, text=text, action=_("tweet")) else: call_threaded(self.session.post_update, text=text)
def NewDm(self, buffer=None, index=None, user="", text=""): """Allows you to send a new direct message to a user.""" who = buffer.get_all_screen_names(index) new = modal_dialog(gui.NewDirectDialog, parent=self.session.frame, default=who[0], selection=who, title=_("Direct message"), text=text) user = new.selection.GetValue() text = new.message.GetValue() if len(text) > self.session.config['lengths']['tweetLength']: logging.info("Direct message too long. Forcing edit.") return self.NewDm (buffer, index, user, text) if new.delay: delay_action(new.delay, self.session.post_dm, text=text, buffer=buffer, index=index, user=user, action=_("dm")) else: call_threaded(self.session.post_dm, buffer=buffer, index=index, user=user, text=text)
def NewReply(self, buffer=None, index=None, text=u"", user=None): """Allows you to post a reply to a tweet.""" default = user users = buffer.get_all_screen_names(index) if 'source' not in buffer[index] and 'text' in buffer[ index] and self.session.config['UI']['DMSafeMode']: return self.NewDm(buffer, index, text) if not self.session.config['UI']['replyToSelf']: for n, u in enumerate(users): if self.session.is_current_user(u): users.remove(users[n]) if default: users.insert(0, default) if not users: return output.speak(_("Unable to detect a user to reply to."), True) new = modal_dialog(gui.NewReplyDialog, parent=self.session.frame, default=users[0], selection=users, title=_("Reply"), text=text) user = new.selection.GetValue() fulltext = templates.replyTemplate(user, new.message.GetValue()) if len(fulltext) > self.session.config['lengths']['tweetLength']: i = fulltext.index(" ") + 1 return self.NewReply(buffer, index, fulltext[i:]) if new.delay: delay_action(new.delay, self.session.post_reply, buffer=buffer, index=index, text=fulltext, action=_("reply")) else: call_threaded(self.session.post_reply, buffer=buffer, index=index, text=fulltext)