mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
load command help text into redis at start
This commit is contained in:
parent
39288bfd1c
commit
202513ee3e
|
@ -502,6 +502,20 @@ var helpText = map[string]string{
|
|||
"xkcd": "Returns a link to the latest xkcd comic. Example usage: ()xkcd",
|
||||
}
|
||||
|
||||
func (app *Application) loadCommandHelp() {
|
||||
for k, v := range helpText {
|
||||
err := app.Rdb.HSet(ctx, "command-help", k, v).Err()
|
||||
if err != nil {
|
||||
app.Logger.Panic(err)
|
||||
}
|
||||
}
|
||||
commandHelpText := app.Rdb.HGetAll(ctx, "command-help").Val()
|
||||
app.Logger.Infow("Successfully loaded command help text into redis",
|
||||
"commandHelpText", commandHelpText,
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
// Help checks if a help text for a given command exists and replies with it.
|
||||
func (app *Application) commandHelp(target, name, username string) {
|
||||
// Check if the `helpText` map has an entry for `name`. If it does return it's value entry
|
||||
|
|
|
@ -210,6 +210,8 @@ func main() {
|
|||
// Start time
|
||||
common.StartTime()
|
||||
|
||||
app.loadCommandHelp()
|
||||
|
||||
// Join the channels in the database.
|
||||
app.InitialJoin()
|
||||
|
||||
|
|
|
@ -262,7 +262,6 @@ func (app *Application) InitialTimers() {
|
|||
if _, err := app.Rdb.Pipelined(ctx, func(rdb redis.Pipeliner) error {
|
||||
rdb.HSet(ctx, cronName, "timer-id", v.ID)
|
||||
rdb.HSet(ctx, cronName, "timer-name", v.Name)
|
||||
rdb.HSet(ctx, cronName, "timer-cronname", cronName)
|
||||
rdb.HSet(ctx, cronName, "timer-text", v.Text)
|
||||
rdb.HSet(ctx, cronName, "timer-channel", v.Channel)
|
||||
rdb.HSet(ctx, cronName, "timer-repeat", v.Repeat)
|
||||
|
|
Loading…
Reference in a new issue