Skip to content

Commit c7b9eca

Browse files
authored
Merge pull request qwibitai#21 from qwibitai/fix/sendmessage-test-parse-mode
fix: sendMessage test expectations for parse_mode
2 parents 555b71b + 587126e commit c7b9eca

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/channels/telegram.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ describe('TelegramChannel', () => {
710710
expect(currentBot().api.sendMessage).toHaveBeenCalledWith(
711711
'100200300',
712712
'Hello',
713+
{ parse_mode: 'Markdown' },
713714
);
714715
});
715716

@@ -723,6 +724,7 @@ describe('TelegramChannel', () => {
723724
expect(currentBot().api.sendMessage).toHaveBeenCalledWith(
724725
'-1001234567890',
725726
'Group message',
727+
{ parse_mode: 'Markdown' },
726728
);
727729
});
728730

@@ -739,11 +741,13 @@ describe('TelegramChannel', () => {
739741
1,
740742
'100200300',
741743
'x'.repeat(4096),
744+
{ parse_mode: 'Markdown' },
742745
);
743746
expect(currentBot().api.sendMessage).toHaveBeenNthCalledWith(
744747
2,
745748
'100200300',
746749
'x'.repeat(904),
750+
{ parse_mode: 'Markdown' },
747751
);
748752
});
749753

src/channels/telegram.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,15 @@ export class TelegramChannel implements Channel {
117117
}
118118

119119
// Store chat metadata for discovery
120-
const isGroup = ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
121-
this.opts.onChatMetadata(chatJid, timestamp, chatName, 'telegram', isGroup);
120+
const isGroup =
121+
ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
122+
this.opts.onChatMetadata(
123+
chatJid,
124+
timestamp,
125+
chatName,
126+
'telegram',
127+
isGroup,
128+
);
122129

123130
// Only deliver full message for registered groups
124131
const group = this.opts.registeredGroups()[chatJid];
@@ -161,8 +168,15 @@ export class TelegramChannel implements Channel {
161168
'Unknown';
162169
const caption = ctx.message.caption ? ` ${ctx.message.caption}` : '';
163170

164-
const isGroup = ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
165-
this.opts.onChatMetadata(chatJid, timestamp, undefined, 'telegram', isGroup);
171+
const isGroup =
172+
ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
173+
this.opts.onChatMetadata(
174+
chatJid,
175+
timestamp,
176+
undefined,
177+
'telegram',
178+
isGroup,
179+
);
166180
this.opts.onMessage(chatJid, {
167181
id: ctx.message.message_id.toString(),
168182
chat_jid: chatJid,
@@ -176,9 +190,7 @@ export class TelegramChannel implements Channel {
176190

177191
this.bot.on('message:photo', (ctx) => storeNonText(ctx, '[Photo]'));
178192
this.bot.on('message:video', (ctx) => storeNonText(ctx, '[Video]'));
179-
this.bot.on('message:voice', (ctx) =>
180-
storeNonText(ctx, '[Voice message]'),
181-
);
193+
this.bot.on('message:voice', (ctx) => storeNonText(ctx, '[Voice message]'));
182194
this.bot.on('message:audio', (ctx) => storeNonText(ctx, '[Audio]'));
183195
this.bot.on('message:document', (ctx) => {
184196
const name = ctx.message.document?.file_name || 'file';

0 commit comments

Comments
 (0)