-
Notifications
You must be signed in to change notification settings - Fork 0
/
title.go
35 lines (31 loc) · 802 Bytes
/
title.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"fmt"
"strings"
"github.com/PaulSonOfLars/gotgbot/v2"
"github.com/PaulSonOfLars/gotgbot/v2/ext"
)
// UserID : Title
var titles = map[int64]string{}
func setTitle(b *gotgbot.Bot, ctx *ext.Context) error {
id := ctx.EffectiveMessage.From.Id
args := getArgs(ctx)
var m string
if len(args) == 0 {
m = titles[id]
if m == "" {
m = "No Title is currently set. Set one using <code>/title your_title_here</code>."
} else {
m = fmt.Sprintf("Your Current Title : <code>%v</code>", m)
}
} else {
m = strings.Join(args, " ")
titles[id] = m
m = "Title set successfully."
}
_, err := ctx.EffectiveMessage.Reply(b, m, &gotgbot.SendMessageOpts{ParseMode: "html"})
if err != nil {
return fmt.Errorf("failed to send setTitle message: %w", err)
}
return nil
}