Added functions to make TWBlue respect Twitter limits when adding media items

This commit is contained in:
Manuel Cortez 2021-11-10 09:47:53 -06:00
parent 8fed52118f
commit 605868eff9
2 changed files with 12 additions and 3 deletions

View File

@ -10,7 +10,6 @@ import config
from pubsub import pub from pubsub import pub
from twitter_text import parse_tweet from twitter_text import parse_tweet
from wxUI.dialogs import twitterDialogs, urlList from wxUI.dialogs import twitterDialogs, urlList
#from wxUI.dialogs import twitterDialogs
from wxUI import commonMessageDialogs from wxUI import commonMessageDialogs
from extra import translator, SpellChecker, autocompletionUsers from extra import translator, SpellChecker, autocompletionUsers
from extra.AudioUploader import audioUploader from extra.AudioUploader import audioUploader
@ -98,6 +97,14 @@ class basicTweet(object):
self.message.PopupMenu(menu, self.message.add.GetPosition()) self.message.PopupMenu(menu, self.message.add.GetPosition())
def on_attach_image(self, *args, **kwargs): def on_attach_image(self, *args, **kwargs):
can_attach = self.can_attach()
video_or_gif_present = False
for a in self.attachments:
if a["type"] == "video" or a["type"] == "gif":
video_or_gif = True
break
if can_attach == False or video_or_gif_present == True:
return self.message.unable_to_attach_file()
image, description = self.message.get_image() image, description = self.message.get_image()
if image != None: if image != None:
if image.endswith("gif"): if image.endswith("gif"):
@ -112,6 +119,8 @@ class basicTweet(object):
self.text_processor() self.text_processor()
def on_attach_video(self, *args, **kwargs): def on_attach_video(self, *args, **kwargs):
if len(self.attachments) > 0:
return self.message.unable_to_attach_file()
video = self.message.get_video() video = self.message.get_video()
if video != None: if video != None:
videoInfo = {"type": "video", "file": video, "description": ""} videoInfo = {"type": "video", "file": video, "description": ""}

View File

@ -145,7 +145,7 @@ class tweet(wx.Dialog):
return openFileDialog.GetPath() return openFileDialog.GetPath()
def unable_to_attach_file(self, *args, **kwargs): def unable_to_attach_file(self, *args, **kwargs):
return wx.MessageDialog(self, _("You need to delete other attachments first, as Videos and GIF's cannot be added with other attachments."), _("Error adding attachment"), wx.ICON_ERROR).ShowModal() return wx.MessageDialog(self, _("It is not possible to add more attachments. Please make sure your tweet complies with Twitter'S attachment rules. You can add only one video or GIF in every tweet, and a maximum of 4 photos."), _("Error adding attachment"), wx.ICON_ERROR).ShowModal()
class reply(tweet): class reply(tweet):