Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/belak/bot
A simple IRC bot framework in Go based off of sorcix/irc - most likely will not be updated
https://github.com/belak/bot
Last synced: about 2 months ago
JSON representation
A simple IRC bot framework in Go based off of sorcix/irc - most likely will not be updated
- Host: GitHub
- URL: https://github.com/belak/bot
- Owner: belak
- Created: 2015-04-03T22:11:33.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-18T07:12:49.000Z (over 9 years ago)
- Last Synced: 2024-10-19T05:51:58.484Z (3 months ago)
- Language: Go
- Homepage:
- Size: 129 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bot
bot is a simple wrapper around https://github.com/sorcix/irc, designed to make
writing bots easier. It is based on https://github.com/belak/irc but with
message parsing now abstracted out.## Muxes
Muxes are one of the most important parts. They make it possible to preprocess
messages and make them easier to handle. Currently, the only Mux included with
the base package is the BasicMux which allows you to register handlers to only
operate on messages with a certain command.## Example
```go
package mainimport (
"log""github.com/belak/bot"
"github.com/sorcix/irc"
)const (
botHost = "chat.freenode.net:6697"botNick = "testbot"
botUser = "bot"
botName = "Herbert"
botPass = ""
)func main() {
b := bot.NewBot(botNick, botUser, botName, botPass)// 001 is a welcome event, so we join channels there
b.Handler.Event("001", func(b *bot.Bot, m *irc.Message) {
b.Send(&irc.Message{
Command: "JOIN",
Params: []string{"#bot-test-chan"},
})
})// Echo replies back to everyone
b.Handler.Event("PRIVMSG", func(b *bot.Bot, m *irc.Message) {
b.MentionReply(m, "%s", m.Trailing())
})err := b.DialTLS(botHost, nil)
if err != nil {
log.Fatalln(err)
}
}
```