fix: handle private chat sender
This commit is contained in:
parent
280c9f51aa
commit
21d69e466e
2 changed files with 13 additions and 3 deletions
|
@ -229,8 +229,15 @@ export class Message {
|
|||
if (this._sender === undefined) {
|
||||
const from = this.raw.fromId
|
||||
if (!from) {
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue