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) {
|
if (this._sender === undefined) {
|
||||||
const from = this.raw.fromId
|
const from = this.raw.fromId
|
||||||
if (!from) {
|
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
|
// anon admin, return the chat
|
||||||
this._sender = this.chat
|
this._sender = this.chat
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
switch (from._) {
|
switch (from._) {
|
||||||
case 'peerChannel': // forwarded channel post
|
case 'peerChannel': // forwarded channel post
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue