mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Some images bugfixes
This commit is contained in:
parent
7e53864173
commit
af3dcb2f7f
2 changed files with 17 additions and 12 deletions
|
@ -107,10 +107,13 @@ class TelegramBot:
|
|||
if update.message is None:
|
||||
return
|
||||
message: telegram.Message = update.message
|
||||
# Skip no-text messages
|
||||
if message.text is None:
|
||||
return
|
||||
text: str = message.text
|
||||
# Try getting the caption instead
|
||||
if text is None:
|
||||
text: str = message.caption
|
||||
# No text or caption, ignore the message
|
||||
if text is None:
|
||||
return
|
||||
# Find and clean parameters
|
||||
command_text, *parameters = text.split(" ")
|
||||
command_text.replace(f"@{self.bot.username}", "")
|
||||
|
|
|
@ -108,6 +108,8 @@ class DiarioCommand(Command):
|
|||
# Check if there's an image associated with the reply
|
||||
photosizes: typing.Optional[typing.List[telegram.PhotoSize]] = reply.photo
|
||||
if photosizes:
|
||||
# Text is a caption
|
||||
text = reply.caption
|
||||
# Python is doing some weird stuff here, self._telegram_to_imgur appears to be unbound?
|
||||
# noinspection PyArgumentList
|
||||
media_url = await self._telegram_to_imgur(self, photosizes, text if text is not None else "")
|
||||
|
@ -132,6 +134,14 @@ class DiarioCommand(Command):
|
|||
timestamp = datetime.datetime.now()
|
||||
# Get the message text
|
||||
raw_text = " ".join(call.args)
|
||||
# Check if there's an image associated with the reply
|
||||
photosizes: typing.Optional[typing.List[telegram.PhotoSize]] = message.photo
|
||||
if photosizes:
|
||||
# Python is doing some weird stuff here, self._telegram_to_imgur appears to be unbound?
|
||||
# noinspection PyArgumentList
|
||||
media_url = await self._telegram_to_imgur(self, photosizes, raw_text if raw_text is not None else "")
|
||||
else:
|
||||
media_url = None
|
||||
# Parse the text, if it exists
|
||||
if raw_text:
|
||||
# Pass the sentence through the diario regex
|
||||
|
@ -167,16 +177,8 @@ class DiarioCommand(Command):
|
|||
quoted_account = None
|
||||
spoiler = False
|
||||
context = None
|
||||
# Check if there's an image associated with the reply
|
||||
photosizes: typing.Optional[typing.List[telegram.PhotoSize]] = message.photo
|
||||
if photosizes:
|
||||
# Python is doing some weird stuff here, self._telegram_to_imgur appears to be unbound?
|
||||
# noinspection PyArgumentList
|
||||
media_url = await self._telegram_to_imgur(self, photosizes, text if text is not None else "")
|
||||
else:
|
||||
media_url = None
|
||||
# Ensure there is a text or an image
|
||||
if not text or media_url:
|
||||
if not (text or media_url):
|
||||
raise InvalidInputError("Missing text.")
|
||||
# Create the diario quote
|
||||
diario = call.alchemy.Diario(creator=creator,
|
||||
|
|
Loading…
Reference in a new issue