Merge pull request #21 from qwibitai/fix/sendmessage-test-parse-mode
fix: sendMessage test expectations for parse_mode
This commit is contained in:
@@ -710,6 +710,7 @@ describe('TelegramChannel', () => {
|
|||||||
expect(currentBot().api.sendMessage).toHaveBeenCalledWith(
|
expect(currentBot().api.sendMessage).toHaveBeenCalledWith(
|
||||||
'100200300',
|
'100200300',
|
||||||
'Hello',
|
'Hello',
|
||||||
|
{ parse_mode: 'Markdown' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -723,6 +724,7 @@ describe('TelegramChannel', () => {
|
|||||||
expect(currentBot().api.sendMessage).toHaveBeenCalledWith(
|
expect(currentBot().api.sendMessage).toHaveBeenCalledWith(
|
||||||
'-1001234567890',
|
'-1001234567890',
|
||||||
'Group message',
|
'Group message',
|
||||||
|
{ parse_mode: 'Markdown' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -739,11 +741,13 @@ describe('TelegramChannel', () => {
|
|||||||
1,
|
1,
|
||||||
'100200300',
|
'100200300',
|
||||||
'x'.repeat(4096),
|
'x'.repeat(4096),
|
||||||
|
{ parse_mode: 'Markdown' },
|
||||||
);
|
);
|
||||||
expect(currentBot().api.sendMessage).toHaveBeenNthCalledWith(
|
expect(currentBot().api.sendMessage).toHaveBeenNthCalledWith(
|
||||||
2,
|
2,
|
||||||
'100200300',
|
'100200300',
|
||||||
'x'.repeat(904),
|
'x'.repeat(904),
|
||||||
|
{ parse_mode: 'Markdown' },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -117,8 +117,15 @@ export class TelegramChannel implements Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store chat metadata for discovery
|
// Store chat metadata for discovery
|
||||||
const isGroup = ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
|
const isGroup =
|
||||||
this.opts.onChatMetadata(chatJid, timestamp, chatName, 'telegram', isGroup);
|
ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
|
||||||
|
this.opts.onChatMetadata(
|
||||||
|
chatJid,
|
||||||
|
timestamp,
|
||||||
|
chatName,
|
||||||
|
'telegram',
|
||||||
|
isGroup,
|
||||||
|
);
|
||||||
|
|
||||||
// Only deliver full message for registered groups
|
// Only deliver full message for registered groups
|
||||||
const group = this.opts.registeredGroups()[chatJid];
|
const group = this.opts.registeredGroups()[chatJid];
|
||||||
@@ -161,8 +168,15 @@ export class TelegramChannel implements Channel {
|
|||||||
'Unknown';
|
'Unknown';
|
||||||
const caption = ctx.message.caption ? ` ${ctx.message.caption}` : '';
|
const caption = ctx.message.caption ? ` ${ctx.message.caption}` : '';
|
||||||
|
|
||||||
const isGroup = ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
|
const isGroup =
|
||||||
this.opts.onChatMetadata(chatJid, timestamp, undefined, 'telegram', isGroup);
|
ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
|
||||||
|
this.opts.onChatMetadata(
|
||||||
|
chatJid,
|
||||||
|
timestamp,
|
||||||
|
undefined,
|
||||||
|
'telegram',
|
||||||
|
isGroup,
|
||||||
|
);
|
||||||
this.opts.onMessage(chatJid, {
|
this.opts.onMessage(chatJid, {
|
||||||
id: ctx.message.message_id.toString(),
|
id: ctx.message.message_id.toString(),
|
||||||
chat_jid: chatJid,
|
chat_jid: chatJid,
|
||||||
@@ -176,9 +190,7 @@ export class TelegramChannel implements Channel {
|
|||||||
|
|
||||||
this.bot.on('message:photo', (ctx) => storeNonText(ctx, '[Photo]'));
|
this.bot.on('message:photo', (ctx) => storeNonText(ctx, '[Photo]'));
|
||||||
this.bot.on('message:video', (ctx) => storeNonText(ctx, '[Video]'));
|
this.bot.on('message:video', (ctx) => storeNonText(ctx, '[Video]'));
|
||||||
this.bot.on('message:voice', (ctx) =>
|
this.bot.on('message:voice', (ctx) => storeNonText(ctx, '[Voice message]'));
|
||||||
storeNonText(ctx, '[Voice message]'),
|
|
||||||
);
|
|
||||||
this.bot.on('message:audio', (ctx) => storeNonText(ctx, '[Audio]'));
|
this.bot.on('message:audio', (ctx) => storeNonText(ctx, '[Audio]'));
|
||||||
this.bot.on('message:document', (ctx) => {
|
this.bot.on('message:document', (ctx) => {
|
||||||
const name = ctx.message.document?.file_name || 'file';
|
const name = ctx.message.document?.file_name || 'file';
|
||||||
|
|||||||
Reference in New Issue
Block a user