-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathhelp.go
More file actions
55 lines (51 loc) · 1.62 KB
/
Copy pathhelp.go
File metadata and controls
55 lines (51 loc) · 1.62 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package modules
import (
"fmt"
"github.com/anonyindian/logger"
"github.com/celestix/gotgproto/dispatcher"
"github.com/celestix/gotgproto/dispatcher/handlers"
"github.com/celestix/gotgproto/ext"
"github.com/gigauserbot/giga/bot"
"github.com/gigauserbot/giga/bot/helpmaker"
"github.com/gotd/td/tg"
)
func (m *module) LoadHelp(dispatcher dispatcher.Dispatcher) {
var l = m.Logger.Create("HELP")
defer l.ChangeLevel(logger.LevelInfo).Println("LOADED")
helpmaker.SetMainHelp("<b><u>The GIGA Userbot</u></b>\n\nHere is the help menu:", "html")
dispatcher.AddHandler(handlers.NewCommand("help", authorised(helpCmd)))
}
func helpCmd(ctx *ext.Context, u *ext.Update) error {
chat := u.EffectiveChat()
result, err := ctx.GetInlineBotResults(chat.GetID(), bot.Username, &tg.MessagesGetInlineBotResultsRequest{
Query: "help",
})
if err != nil {
ctx.EditMessage(chat.GetID(), &tg.MessagesEditMessageRequest{
ID: u.EffectiveMessage.ID,
Message: fmt.Sprintf("failed to load help: %s", err.Error()),
})
return dispatcher.EndGroups
}
ctx.SendInlineBotResult(chat.GetID(), &tg.MessagesSendInlineBotResultRequest{
HideVia: true,
QueryID: result.QueryID,
ID: result.Results[0].GetID(),
})
switch {
case chat.IsAChannel():
ctx.Raw.ChannelsDeleteMessages(ctx, &tg.ChannelsDeleteMessagesRequest{
Channel: &tg.InputChannel{
ChannelID: chat.GetID(),
AccessHash: chat.GetAccessHash(),
},
ID: []int{u.EffectiveMessage.ID},
})
default:
ctx.Raw.MessagesDeleteMessages(ctx, &tg.MessagesDeleteMessagesRequest{
Revoke: true,
ID: []int{u.EffectiveMessage.ID},
})
}
return dispatcher.EndGroups
}