Skip to content

Commit

Permalink
0.31.3
Browse files Browse the repository at this point in the history
smart crop flag
unsupported message text
  • Loading branch information
LyoSU committed Jan 4, 2022
1 parent 0a3b789 commit 9f29f5c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion handlers/quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ module.exports = async (ctx, next) => {
rate: false,
color: false,
scale: false,
crop: false,
privacy: false
}

Expand All @@ -104,6 +105,7 @@ module.exports = async (ctx, next) => {
flag.hidden = args.find((arg) => ['h', 'hidden'].includes(arg))
flag.media = args.find((arg) => ['m', 'media'].includes(arg))
flag.scale = args.find((arg) => arg.match(/s([+-]?(?:\d*\.)?\d+)/))
flag.crop = args.find((arg) => ['c', 'crop'].includes(arg))
flag.color = args.find((arg) => (!Object.values(flag).find((f) => arg === f)))

if (flag.scale) flag.scale = flag.scale.match(/s([+-]?(?:\d*\.)?\d+)/)[1]
Expand Down Expand Up @@ -278,7 +280,10 @@ module.exports = async (ctx, next) => {
message.entities = quoteMessage.entities
}

if (!text) flag.media = true
if (!text) {
flag.media = true
message.mediaCrop = flag.crop || false
}
if (flag.media && quoteMessage.photo) message.media = quoteMessage.photo
if (flag.media && quoteMessage.sticker) {
message.media = [quoteMessage.sticker]
Expand Down Expand Up @@ -332,6 +337,15 @@ module.exports = async (ctx, next) => {
if (replyMessageInfo.entities) message.replyMessage.entities = replyMessageInfo.entities
}

if (!message.text && !message.media) {
message.text = 'Unsupported message'
message.entities = [{
offset: 0,
length: 19,
type: 'italic'
}]
}

quoteMessages[index] = message

lastMessage = quoteMessage
Expand Down
2 changes: 1 addition & 1 deletion helpers/tdlib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function getMessages (chatID, messageIds) {

message[type] = media
} else {
messageInfo.content.unsupportedMedia = {}
message.unsupportedMessage = true
}

if (messageInfo.content.caption) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quote-bot",
"version": "0.31.2",
"version": "0.31.3",
"description": "Telegram quote bot",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 9f29f5c

Please sign in to comment.