mirror of https://github.com/velour/catbase.git
Added a skeleton plugin (and beers based on that) and improved the help function
a bit.
This commit is contained in:
parent
ad2e0f13e2
commit
59b42b1556
|
@ -48,9 +48,9 @@ func (b *Bot) Msg_recieved(conn *irc.Conn, line *irc.Line) {
|
||||||
if len(parts) > 0 && parts[0] == "help" {
|
if len(parts) > 0 && parts[0] == "help" {
|
||||||
if len(parts) == 1 {
|
if len(parts) == 1 {
|
||||||
// just print out a list of help topics
|
// just print out a list of help topics
|
||||||
topics := "Help topics: About"
|
topics := "Help topics: about"
|
||||||
for name, _ := range b.Plugins {
|
for name, _ := range b.Plugins {
|
||||||
topics = fmt.Sprintf("%s, %s ", topics, name)
|
topics = fmt.Sprintf("%s, %s", topics, name)
|
||||||
}
|
}
|
||||||
b.SendMessage(channel, topics)
|
b.SendMessage(channel, topics)
|
||||||
} else {
|
} else {
|
||||||
|
|
4
main.go
4
main.go
|
@ -43,7 +43,9 @@ func main() {
|
||||||
|
|
||||||
b := bot.NewBot(config, c)
|
b := bot.NewBot(config, c)
|
||||||
// b.AddHandler(plugins.NewTestPlugin(b))
|
// b.AddHandler(plugins.NewTestPlugin(b))
|
||||||
b.AddHandler("Talker", plugins.NewTalkerPlugin(b))
|
b.AddHandler("talker", plugins.NewTalkerPlugin(b))
|
||||||
|
b.AddHandler("beers", plugins.NewBeersPlugin(b))
|
||||||
|
b.AddHandler("skeleton", plugins.NewSkeletonPlugin(b))
|
||||||
|
|
||||||
c.AddHandler("PRIVMSG", func(conn *irc.Conn, line *irc.Line) {
|
c.AddHandler("PRIVMSG", func(conn *irc.Conn, line *irc.Line) {
|
||||||
b.Msg_recieved(conn, line)
|
b.Msg_recieved(conn, line)
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package plugins
|
||||||
|
|
||||||
|
import "bitbucket.org/phlyingpenguin/godeepintir/bot"
|
||||||
|
|
||||||
|
// This is a skeleton plugin to serve as an example and quick copy/paste for new plugins.
|
||||||
|
|
||||||
|
type BeersPlugin struct {
|
||||||
|
Bot *bot.Bot
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewBeersPlugin creates a new BeersPlugin with the Plugin interface
|
||||||
|
func NewBeersPlugin(bot *bot.Bot) *BeersPlugin {
|
||||||
|
return &BeersPlugin{
|
||||||
|
Bot: bot,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message responds to the bot hook on recieving messages.
|
||||||
|
// This function returns true if the plugin responds in a meaningful way to the users message.
|
||||||
|
// Otherwise, the function returns false and the bot continues execution of other plugins.
|
||||||
|
func (p *BeersPlugin) Message(message bot.Message) bool {
|
||||||
|
// This bot does not reply to anything
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadData imports any configuration data into the plugin. This is not strictly necessary other
|
||||||
|
// than the fact that the Plugin interface demands it exist. This may be deprecated at a later
|
||||||
|
// date.
|
||||||
|
func (p *BeersPlugin) LoadData() {
|
||||||
|
// This bot has no data to load
|
||||||
|
}
|
||||||
|
|
||||||
|
// Help responds to help requests. Every plugin must implement a help function.
|
||||||
|
func (p *BeersPlugin) Help(channel string, parts []string) {
|
||||||
|
p.Bot.SendMessage(channel, "Sorry, Beers does not do a goddamn thing.")
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package plugins
|
||||||
|
|
||||||
|
import "bitbucket.org/phlyingpenguin/godeepintir/bot"
|
||||||
|
|
||||||
|
// This is a skeleton plugin to serve as an example and quick copy/paste for new plugins.
|
||||||
|
|
||||||
|
type SkeletonPlugin struct {
|
||||||
|
Bot *bot.Bot
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSkeletonPlugin creates a new SkeletonPlugin with the Plugin interface
|
||||||
|
func NewSkeletonPlugin(bot *bot.Bot) *SkeletonPlugin {
|
||||||
|
return &SkeletonPlugin{
|
||||||
|
Bot: bot,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message responds to the bot hook on recieving messages.
|
||||||
|
// This function returns true if the plugin responds in a meaningful way to the users message.
|
||||||
|
// Otherwise, the function returns false and the bot continues execution of other plugins.
|
||||||
|
func (p *SkeletonPlugin) Message(message bot.Message) bool {
|
||||||
|
// This bot does not reply to anything
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadData imports any configuration data into the plugin. This is not strictly necessary other
|
||||||
|
// than the fact that the Plugin interface demands it exist. This may be deprecated at a later
|
||||||
|
// date.
|
||||||
|
func (p *SkeletonPlugin) LoadData() {
|
||||||
|
// This bot has no data to load
|
||||||
|
}
|
||||||
|
|
||||||
|
// Help responds to help requests. Every plugin must implement a help function.
|
||||||
|
func (p *SkeletonPlugin) Help(channel string, parts []string) {
|
||||||
|
p.Bot.SendMessage(channel, "Sorry, Skeleton does not do a goddamn thing.")
|
||||||
|
}
|
Loading…
Reference in New Issue