Skip to content

Commit

Permalink
Add emoji reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
soruly committed Mar 10, 2024
1 parent 73b3b26 commit ba4c0cd
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ const sendChatAction = (chat_id, action) =>
.then((e) => e.json())
.then((e) => e.result);

const setMessageReaction = (chat_id, message_id, emoji_list, is_big) =>
fetch(`${TELEGRAM_API}/bot${TELEGRAM_TOKEN}/setMessageReaction`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
chat_id,
message_id,
reaction: emoji_list.map((emoji) => ({ type: "emoji", emoji })),
is_big,
}),
})
.then((e) => e.json())
.then((e) => e.result);

const sendVideo = (chat_id, video, options) =>
fetch(`${TELEGRAM_API}/bot${TELEGRAM_TOKEN}/sendVideo`, {
method: "POST",
Expand Down Expand Up @@ -323,6 +337,7 @@ const privateMessageHandler = async (message) => {
return await sendMessage(message.chat.id, "You can Send / Forward anime screenshots to me.");
}

await setMessageReaction(message.chat.id, responding_msg.message_id, ["👌"]);
await sendChatAction(message.chat.id, "typing");

const result = await submitSearch(imageURL, responding_msg, message);
Expand All @@ -336,6 +351,7 @@ const privateMessageHandler = async (message) => {
parse_mode: "Markdown",
reply_to_message_id: responding_msg.message_id,
});
await setMessageReaction(message.chat.id, responding_msg.message_id, []);
return;
}
}
Expand All @@ -344,6 +360,7 @@ const privateMessageHandler = async (message) => {
reply_to_message_id: responding_msg.message_id,
parse_mode: "Markdown",
});
await setMessageReaction(message.chat.id, responding_msg.message_id, []);
};

const groupMessageHandler = async (message) => {
Expand All @@ -366,7 +383,7 @@ const groupMessageHandler = async (message) => {
{ reply_to_message_id: message.message_id },
);
}

await setMessageReaction(message.chat.id, responding_msg.message_id, ["👌"]);
await sendChatAction(message.chat.id, "typing");

const result = await submitSearch(imageURL, responding_msg, message);
Expand All @@ -379,6 +396,7 @@ const groupMessageHandler = async (message) => {
reply_to_message_id: responding_msg.message_id,
},
);
await setMessageReaction(message.chat.id, responding_msg.message_id, []);
return;
}

Expand All @@ -392,6 +410,7 @@ const groupMessageHandler = async (message) => {
parse_mode: "Markdown",
reply_to_message_id: responding_msg.message_id,
});
await setMessageReaction(message.chat.id, responding_msg.message_id, []);
return;
}
}
Expand All @@ -400,6 +419,7 @@ const groupMessageHandler = async (message) => {
parse_mode: "Markdown",
reply_to_message_id: responding_msg.message_id,
});
await setMessageReaction(message.chat.id, responding_msg.message_id, []);
};

app.post("/", (req, res) => {
Expand Down

0 comments on commit ba4c0cd

Please sign in to comment.