fix: handle private chat sender

This commit is contained in:
teidesu 2021-06-07 15:27:16 +03:00
parent 280c9f51aa
commit 21d69e466e
2 changed files with 13 additions and 3 deletions

View file

@ -229,8 +229,15 @@ export class Message {
if (this._sender === undefined) {
const from = this.raw.fromId
if (!from) {
// anon admin, return the chat
this._sender = this.chat
if (this.raw.peerId._ === 'peerUser') {
this._sender = new User(
this.client,
this._users[this.raw.peerId.userId]
)
} else {
// anon admin, return the chat
this._sender = this.chat
}
} else
switch (from._) {
case 'peerChannel': // forwarded channel post

View file

@ -300,7 +300,10 @@ export namespace filters {
*/
export const chat = <T extends Chat.Type>(
type: T
): UpdateFilter<Message, { chat: Modify<Chat, { type: T }> }> => (msg) =>
): UpdateFilter<Message, {
chat: Modify<Chat, { type: T }>
sender: T extends 'private' | 'bot' | 'group' ? User : User | Chat
}> => (msg) =>
msg.chat.type === type
/**