From a37f7b432fcb96ebc91fe69c2023c0543fe7161c Mon Sep 17 00:00:00 2001 From: "josejisin@gmail.com" Date: Sat, 20 Jul 2024 14:07:21 +0100 Subject: [PATCH] feat: id command and description --- README.md | 1 + plugins/id.go | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6d35980..5a4c380 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ genlink - Create a link for a single message. about - Basic Information About the bot. help - Short Guide on How to Use the Bot. privacy - Read about the privacy policy. +id - Get user id or forwarded channel id. ``` ## Variables diff --git a/plugins/id.go b/plugins/id.go index c572ea4..fddc578 100644 --- a/plugins/id.go +++ b/plugins/id.go @@ -19,25 +19,27 @@ func ID(bot *gotgbot.Bot, ctx *ext.Context) error { var output strings.Builder - output.WriteString(fmt.Sprintf("Sender ID : %d", sender.Id())) + output.WriteString(fmt.Sprintf("Sender ID : %d\n", sender.Id())) - if forward := update.ForwardOrigin; forward != nil { - merged := forward.MergeMessageOrigin() + if reply := update.ReplyToMessage; reply != nil { + if forward := reply.ForwardOrigin; forward != nil { + merged := forward.MergeMessageOrigin() - if merged.Chat != nil { - output.WriteString(fmt.Sprintf("Forwarded From : %d", merged.Chat.Id)) - } + if merged.Chat != nil { + output.WriteString(fmt.Sprintf("Forwarded From : %d\n", merged.Chat.Id)) + } - if merged.SenderChat != nil { - output.WriteString(fmt.Sprintf("Forwarded Group : %d", merged.SenderChat.Id)) - } + if merged.SenderChat != nil { + output.WriteString(fmt.Sprintf("Forwarded Group : %d\n", merged.SenderChat.Id)) + } - if merged.SenderUser != nil { - output.WriteString(fmt.Sprintf("Forwarded User : %d", merged.SenderUser.Id)) - } + if merged.SenderUser != nil { + output.WriteString(fmt.Sprintf("Forwarded User : %d\n", merged.SenderUser.Id)) + } - if merged.SenderUserName != "" { - output.WriteString(fmt.Sprintf("Forwarded Username : %s", merged.SenderUserName)) + if merged.SenderUserName != "" { + output.WriteString(fmt.Sprintf("Forwarded Username : %s\n", merged.SenderUserName)) + } } }