Skip to content

Commit

Permalink
fix: work with typegram provided fix for reply_to_message
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo committed Jan 11, 2021
1 parent 9a87f69 commit df78fd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion source/identifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const BASE_URL = 'http://t.me/#'
const URL_SEPERATOR = '#'

// TODO: refactor when GuardedContext (or whatever its named) is out (see https://github.com/telegraf/telegraf/discussions/1284)
type ReplyToMessage = Message // NonNullable<Message.CommonMessage['reply_to_message']>
type ReplyToMessage = NonNullable<Message.CommonMessage['reply_to_message']>
export type ReplyToMessageContext<Context extends TelegrafContext> = Context & {message: Message.CommonMessage & {reply_to_message: ReplyToMessage}}
export type UrlMessageEntity = Readonly<MessageEntity.TextLinkMessageEntity>

Expand Down
18 changes: 6 additions & 12 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,8 @@ test('ignores message replying to something else', async t => {
from: {id: 42, first_name: 'Bob', is_bot: true},
chat: {id: 42, type: 'private', first_name: 'Bob'},
date: 10,
// @ts-expect-error typegram typings seem strange here
text: 'whatever'
}
} as any
}
})
})
Expand Down Expand Up @@ -244,15 +243,14 @@ test('ignores message replying to something else with entities', async t => {
from: {id: 42, first_name: 'Bob', is_bot: true},
chat: {id: 42, type: 'private', first_name: 'Bob'},
date: 10,
// @ts-expect-error typegram typings seem strange here
text: 'whatever',
entities: [{
type: 'text_link',
url: 'http://t.me/EdJoPaTo',
offset: 0,
length: 2
}]
}
} as any
}
})
})
Expand Down Expand Up @@ -280,15 +278,14 @@ test('ignores message replying to another question', async t => {
from: {id: 42, first_name: 'Bob', is_bot: true},
chat: {id: 42, type: 'private', first_name: 'Bob'},
date: 10,
// @ts-expect-error typegram typings seem strange here
text: 'whatever',
entities: [{
type: 'text_link',
url: 'http://t.me/#other#',
offset: 0,
length: 2
}]
}
} as any
}
})
})
Expand Down Expand Up @@ -317,15 +314,14 @@ test('correctly works with text message', async t => {
from: {id: 42, first_name: 'Bob', is_bot: true},
chat: {id: 42, type: 'private', first_name: 'Bob'},
date: 10,
// @ts-expect-error typegram typings seem strange here
text: 'whatever',
entities: [{
type: 'text_link',
url: 'http://t.me/#unicorns#',
offset: 0,
length: 2
}]
}
} as any
}
})
})
Expand Down Expand Up @@ -355,15 +351,14 @@ test('correctly works with text message with additional state', async t => {
from: {id: 42, first_name: 'Bob', is_bot: true},
chat: {id: 42, type: 'private', first_name: 'Bob'},
date: 10,
// @ts-expect-error typegram typings seem strange here
text: 'whatever',
entities: [{
type: 'text_link',
url: 'http://t.me/#unicorns#explode',
offset: 0,
length: 2
}]
}
} as any
}
})
})
Expand Down Expand Up @@ -392,7 +387,6 @@ test('correctly works with media message', async t => {
from: {id: 42, first_name: 'Bob', is_bot: true},
chat: {id: 42, type: 'private', first_name: 'Bob'},
date: 10,
// @ts-expect-error typegram typings seem strange here
photo: [],
caption: 'whatever',
caption_entities: [{
Expand All @@ -401,7 +395,7 @@ test('correctly works with media message', async t => {
offset: 0,
length: 2
}]
}
} as any
}
})
})

0 comments on commit df78fd1

Please sign in to comment.