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 twitter_text import parse_tweet
from wxUI.dialogs import twitterDialogs, urlList
#from wxUI.dialogs import twitterDialogs
from wxUI import commonMessageDialogs
from extra import translator, SpellChecker, autocompletionUsers
from extra.AudioUploader import audioUploader
@ -87,7 +86,7 @@ class basicTweet(object):
return False
elif len(self.attachments) < 4:
return True
return False
return False
def on_attach(self, *args, **kwargs):
can_attach = self.can_attach()
@ -98,6 +97,14 @@ class basicTweet(object):
self.message.PopupMenu(menu, self.message.add.GetPosition())
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()
if image != None:
if image.endswith("gif"):
@ -112,6 +119,8 @@ class basicTweet(object):
self.text_processor()
def on_attach_video(self, *args, **kwargs):
if len(self.attachments) > 0:
return self.message.unable_to_attach_file()
video = self.message.get_video()
if video != None:
videoInfo = {"type": "video", "file": video, "description": ""}

View File

@ -145,7 +145,7 @@ class tweet(wx.Dialog):
return openFileDialog.GetPath()
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):