diff --git a/src/controller/buffers/twitter/base.py b/src/controller/buffers/twitter/base.py index 34196b7b..1d81a604 100644 --- a/src/controller/buffers/twitter/base.py +++ b/src/controller/buffers/twitter/base.py @@ -408,8 +408,8 @@ class BaseBuffer(base.Buffer): if len(users) > 0: config.app["app-settings"]["mention_all"] = message.message.mention_all.GetValue() config.app.write() - tweet_data = dict(text=message.message.text.GetValue(), attachments=message.attachments) - call_threaded(self.session.reply, in_reply_to_status_id=id, text=message.message.text.GetValue(), attachments=message.attachments, exclude_reply_user_ids=message.get_ids(), auto_populate_reply_metadata=True) + tweet_data = dict(text=message.message.text.GetValue(), attachments=message.attachments, poll_options=message.poll_options, poll_period=message.poll_period) + call_threaded(self.session.reply, in_reply_to_status_id=id, text=message.message.text.GetValue(), attachments=message.attachments, exclude_reply_user_ids=message.get_ids()) if hasattr(message.message, "destroy"): message.message.destroy() self.session.settings.write() diff --git a/src/controller/buffers/twitter/directMessages.py b/src/controller/buffers/twitter/directMessages.py index 60090c89..06cbed9a 100644 --- a/src/controller/buffers/twitter/directMessages.py +++ b/src/controller/buffers/twitter/directMessages.py @@ -92,8 +92,8 @@ class DirectMessagesBuffer(base.BaseBuffer): screen_name = self.session.get_user(tweet.message_create["sender_id"]).screen_name message = messages.reply(session=self.session, title=_("Mention"), caption=_("Mention to %s") % (screen_name,), text="@%s " % (screen_name,), thread_mode=False, users=[screen_name,]) if message.message.ShowModal() == widgetUtils.OK: - tweet_data = dict(text=message.message.text.GetValue(), attachments=message.attachments) - call_threaded(self.session.send_tweet, *[tweet_data]) + tweet_data = message.get_tweet_data() + call_threaded(self.session.send_tweet, tweet_data) if hasattr(message.message, "destroy"): message.message.destroy() diff --git a/src/controller/buffers/twitter/people.py b/src/controller/buffers/twitter/people.py index faf03794..d29a46dc 100644 --- a/src/controller/buffers/twitter/people.py +++ b/src/controller/buffers/twitter/people.py @@ -94,8 +94,8 @@ class PeopleBuffer(base.BaseBuffer): screen_name = tweet.screen_name message = messages.tweet(session=self.session, title=_("Mention"), caption=_("Mention to %s") % (screen_name,), text="@%s " % (screen_name,), thread_mode=False) if message.message.ShowModal() == widgetUtils.OK: - tweet_data = dict(text=message.message.text.GetValue(), attachments=message.attachments) - call_threaded(self.session.send_tweet, *[tweet_data]) + tweet_data = message.get_tweet_data() + call_threaded(self.session.send_tweet, tweet_data) if hasattr(message.message, "destroy"): message.message.destroy() diff --git a/src/controller/buffers/twitter/trends.py b/src/controller/buffers/twitter/trends.py index ab623e05..39809df1 100644 --- a/src/controller/buffers/twitter/trends.py +++ b/src/controller/buffers/twitter/trends.py @@ -131,21 +131,13 @@ class TrendsBuffer(base.Buffer): def tweet_about_this_trend(self, *args, **kwargs): if self.buffer.list.get_count() == 0: return - title = _(u"Tweet") - caption = _(u"Write the tweet here") - tweet = messages.tweet(self.session, title, caption, self.get_message()+ " ") - tweet.message.set_cursor_at_end() - if tweet.message.get_response() == widgetUtils.OK: - text = tweet.message.get_text() - if len(text) > 280 and tweet.message.get("long_tweet") == True: - if tweet.image == None: - text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text) - else: - text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text, 1) - if tweet.image == None: - call_threaded(self.session.api_call, call_name="update_status", status=text) - else: - call_threaded(self.session.api_call, call_name="update_status_with_media", status=text, media=tweet.image) + title = _("Tweet") + caption = _("Write the tweet here") + tweet = messages.tweet(session=self.session, title=title, caption=caption, text=self.get_message()+ " ") + tweet.message.SetInsertionPoint(len(tweet.message.GetValue())) + if tweet.message.ShowModal() == widgetUtils.OK: + tweet_data = tweet.get_tweet_data() + call_threaded(self.session.send_tweet, *tweet_data) if hasattr(tweet.message, "destroy"): tweet.message.destroy() def show_menu_by_key(self, ev): diff --git a/src/controller/messages.py b/src/controller/messages.py index 3fb52d38..421be6d7 100644 --- a/src/controller/messages.py +++ b/src/controller/messages.py @@ -93,7 +93,8 @@ class basicTweet(object): menu = self.message.attach_menu(can_attach) self.message.Bind(wx.EVT_MENU, self.on_attach_image, self.message.add_image) self.message.Bind(wx.EVT_MENU, self.on_attach_video, self.message.add_video) - self.message.Bind(wx.EVT_MENU, self.on_attach_poll, self.message.add_poll) + if hasattr(self.message, "add_poll"): + self.message.Bind(wx.EVT_MENU, self.on_attach_poll, self.message.add_poll) self.message.PopupMenu(menu, self.message.add.GetPosition()) def on_attach_image(self, *args, **kwargs): @@ -243,10 +244,10 @@ class reply(tweet): i.Show() def get_ids(self): - excluded_ids = "" + excluded_ids = [] for i in range(0, len(self.message.checkboxes)): if self.message.checkboxes[i].GetValue() == False: - excluded_ids = excluded_ids + "{0},".format(self.ids[i],) + excluded_ids.append(self.ids[i]) return excluded_ids def get_people(self): diff --git a/src/sessions/twitter/session.py b/src/sessions/twitter/session.py index 40f40df5..38f4baae 100644 --- a/src/sessions/twitter/session.py +++ b/src/sessions/twitter/session.py @@ -636,7 +636,7 @@ class Session(base.baseSession): def reply(self, text="", in_reply_to_status_id=None, attachments=[], *args, **kwargs): if len(attachments) == 0: - item = self.api_call(call_name="update_status", status=text, _sound="reply_send.ogg", tweet_mode="extended", in_reply_to_status_id=in_reply_to_status_id, *args, **kwargs) + item = self.api_call_v2(call_name="create_tweet", text=text, _sound="reply_send.ogg", in_reply_to_tweet_id=in_reply_to_status_id, *args, **kwargs) else: media_ids = [] for i in attachments: diff --git a/src/wxUI/dialogs/twitterDialogs/tweetDialogs.py b/src/wxUI/dialogs/twitterDialogs/tweetDialogs.py index d5fd35a6..84ea5fde 100644 --- a/src/wxUI/dialogs/twitterDialogs/tweetDialogs.py +++ b/src/wxUI/dialogs/twitterDialogs/tweetDialogs.py @@ -217,6 +217,14 @@ class reply(tweet): self.SetEscapeId(self.cancel.GetId()) self.Layout() + def attach_menu(self, event=None, enabled=True, *args, **kwargs): + menu = wx.Menu() + self.add_image = menu.Append(wx.ID_ANY, _("Image")) + self.add_image.Enable(enabled) + self.add_video = menu.Append(wx.ID_ANY, _("Video")) + self.add_video.Enable(enabled) + return menu + class dm(tweet): def __init__(self, users: List[str] = [], *args, **kwargs) -> None: