feat: support channel

This commit is contained in:
Kyle Fang
2024-06-15 20:44:59 +08:00
parent 9f986feb9a
commit f76d16be25

View File

@@ -130,17 +130,15 @@ const cors: Middleware = async ({ res }, next) => {
new Application().use(cors).use(router.middleware).listen(); new Application().use(cors).use(router.middleware).listen();
async function processUpdate(update: Update): Promise<void> { async function processUpdate(update: Update): Promise<void> {
if (update.message == null) { const message = update.message ?? update.channel_post;
if (message == null) {
return; return;
} }
if ( if (message.text === "/webhook" || message.text === "/webhook@telerts_bot") {
update.message.text === "/webhook" || const chatId = message.chat.id;
update.message.text === "/webhook@telerts_bot"
) {
const chatId = update.message.chat.id;
const chat = { const chat = {
chatId, chatId,
messageThreadId: update.message.message_thread_id, messageThreadId: message.message_thread_id,
}; };
const chatKey = JSON.stringify(chat); const chatKey = JSON.stringify(chat);
const key = `chat-webhook:${chatKey}`; const key = `chat-webhook:${chatKey}`;