mirror of https://github.com/velour/catbase.git
Moved welcome messages to config file for easier updating
This commit is contained in:
parent
172567004a
commit
0552c5048d
|
@ -18,6 +18,12 @@
|
||||||
|
|
||||||
"comment": "Follows is the old bot",
|
"comment": "Follows is the old bot",
|
||||||
|
|
||||||
|
"WelcomeMsgs": [
|
||||||
|
"Real men use screen, %s.",
|
||||||
|
"Joins upset the hivemind's OCD, %s.",
|
||||||
|
"Joins upset the hivemind's CDO, %s.",
|
||||||
|
],
|
||||||
|
|
||||||
"bot": {
|
"bot": {
|
||||||
"dbname": "deepintir",
|
"dbname": "deepintir",
|
||||||
"inchan": "out",
|
"inchan": "out",
|
||||||
|
|
|
@ -21,6 +21,7 @@ type Config struct {
|
||||||
Admins []string
|
Admins []string
|
||||||
UntappdToken string
|
UntappdToken string
|
||||||
UntappdFreq int
|
UntappdFreq int
|
||||||
|
WelcomeMsgs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Readconfig loads the config data out of a JSON file located in cfile
|
// Readconfig loads the config data out of a JSON file located in cfile
|
||||||
|
|
|
@ -55,11 +55,7 @@ func (p *TalkerPlugin) Help(channel string, parts []string) {
|
||||||
// Empty event handler because this plugin does not do anything on event recv
|
// Empty event handler because this plugin does not do anything on event recv
|
||||||
func (p *TalkerPlugin) Event(kind string, message bot.Message) bool {
|
func (p *TalkerPlugin) Event(kind string, message bot.Message) bool {
|
||||||
if kind == "JOIN" && message.User.Name != p.Bot.Config.Nick {
|
if kind == "JOIN" && message.User.Name != p.Bot.Config.Nick {
|
||||||
sayings := []string{
|
sayings := p.Bot.Config.WelcomeMsgs
|
||||||
"Real men use screen, %s.",
|
|
||||||
"Joins upset the hivemind's OCD, %s.",
|
|
||||||
"Joins upset the hivemind's CDO, %s.",
|
|
||||||
}
|
|
||||||
msg := fmt.Sprintf(sayings[rand.Intn(len(sayings))], message.User.Name)
|
msg := fmt.Sprintf(sayings[rand.Intn(len(sayings))], message.User.Name)
|
||||||
p.Bot.SendMessage(message.Channel, msg)
|
p.Bot.SendMessage(message.Channel, msg)
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue