Skip to content

Commit

Permalink
feat: id command and description
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisin0 committed Jul 20, 2024
1 parent 6b34458 commit a37f7b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 16 additions & 14 deletions plugins/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@ func ID(bot *gotgbot.Bot, ctx *ext.Context) error {

var output strings.Builder

output.WriteString(fmt.Sprintf("Sender ID : <code>%d</code>", sender.Id()))
output.WriteString(fmt.Sprintf("<b>Sender ID</b> : <code>%d</code>\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 : <code>%d</code>", merged.Chat.Id))
}
if merged.Chat != nil {
output.WriteString(fmt.Sprintf("<b>Forwarded From</b> : <code>%d</code>\n", merged.Chat.Id))
}

if merged.SenderChat != nil {
output.WriteString(fmt.Sprintf("Forwarded Group : <code>%d</code>", merged.SenderChat.Id))
}
if merged.SenderChat != nil {
output.WriteString(fmt.Sprintf("<b>Forwarded Group</b> : <code>%d</code>\n", merged.SenderChat.Id))
}

if merged.SenderUser != nil {
output.WriteString(fmt.Sprintf("Forwarded User : <code>%d</code>", merged.SenderUser.Id))
}
if merged.SenderUser != nil {
output.WriteString(fmt.Sprintf("<b>Forwarded User</b> : <code>%d</code>\n", merged.SenderUser.Id))
}

if merged.SenderUserName != "" {
output.WriteString(fmt.Sprintf("Forwarded Username : <code>%s</code>", merged.SenderUserName))
if merged.SenderUserName != "" {
output.WriteString(fmt.Sprintf("<b>Forwarded Username</b> : <code>%s</code>\n", merged.SenderUserName))
}
}
}

Expand Down

0 comments on commit a37f7b4

Please sign in to comment.