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) { if (this._sender === undefined) {
const from = this.raw.fromId const from = this.raw.fromId
if (!from) { if (!from) {
// anon admin, return the chat if (this.raw.peerId._ === 'peerUser') {
this._sender = this.chat this._sender = new User(
this.client,
this._users[this.raw.peerId.userId]
)
} else {
// anon admin, return the chat
this._sender = this.chat
}
} else } else
switch (from._) { switch (from._) {
case 'peerChannel': // forwarded channel post case 'peerChannel': // forwarded channel post

View file

@ -300,7 +300,10 @@ export namespace filters {
*/ */
export const chat = <T extends Chat.Type>( export const chat = <T extends Chat.Type>(
type: T 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 msg.chat.type === type
/** /**