/
bot.go
45 lines (33 loc) · 1.28 KB
/
bot.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
36
37
38
39
40
41
42
43
44
45
// Brief: Bot logic
// Primary responsibility: Top level logic layer for bot
package bot
import (
"fmt"
"log"
"github.com/julwrites/BotPlatform/pkg/def"
"github.com/julwrites/ScriptureBot/pkg/app"
)
func HelpMessage(env *def.SessionData) string {
return fmt.Sprintf("Hello %s! Give me a Bible reference and I'll give you the passage!\nHere are some other things I can do:\n/version - Choose your preferred Bible version\n/tms - Get a card from the Navigators' Topical Memory System\n/devo - Get reading material right now\n/lexicon - Search for a passage, lexicon entry, word or phrase\n", env.User.Firstname)
//\n/subscribe - Subscribe to / Unsubscribe from daily reading material
}
func RunCommands(env def.SessionData) def.SessionData {
if len(env.User.Action) > 0 {
log.Printf("Detected user has active action %s", env.User.Action)
env.Msg.Command = env.User.Action
}
if env.Msg.Message == app.CMD_CLOSE {
env.Msg.Command = app.CMD_CLOSE
}
env = app.ProcessCommand(env)
return env
}
func HandleBotLogic(env def.SessionData) def.SessionData {
env = RunCommands(env)
// log.Printf("Commands run, resulting message: %s", env.Res.Message)
if len(env.Res.Message) == 0 {
log.Printf("This message was not handled by bot")
env.Res.Message = HelpMessage(&env)
}
return env
}