• Stars
    star
    135
  • Rank 267,785 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created about 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A hella awesome irc bot framework written in go, Simply plug in your triggers and run!

HellaBot

GoDoc

One hella-awesome Internet Relay Chat (IRC) bot. Hellabot is an easily hackable event based IRC bot framework with the ability to be updated without losing connection to the server. To respond to an event, simply create a "Trigger" struct containing two functions, one for the condition, and one for the action.

Example Trigger

var MyTrigger = hbot.Trigger{
	func (b *hbot.Bot, m *hbot.Message) bool {
		return m.From == "whyrusleeping"
	},
	func (b *hbot.Bot, m *hbot.Message) bool {
		b.Reply(m, "whyrusleeping said something")
		return false
	},
}

The trigger makes the bot announce to everyone that something was said in the current channel. Use the code snippet below to make the bot and add the trigger.

mybot, err := hbot.NewBot("irc.freenode.net:6667","hellabot")
if err != nil {
    panic(err)
}
mybot.AddTrigger(MyTrigger)
mybot.Run() // Blocks until exit

The 'To' field on the message object in triggers will refer to the channel that a given message is in, unless it is a server message, or a user to user private message. In such cases, the field will be the target user's name.

For more example triggers, check the examples directory.

The Message struct

The message struct is primarily what you will be dealing with when building triggers or reading off the Incoming channel. This is mainly the sorcix.Message struct with some additions. See https://github.com/sorcix/irc/blob/master/message.go#L153

 // Message represents a message received from the server
 type Message struct {
     // irc.Message from sorcix
     *irc.Message
     // Content generally refers to the text of a PRIVMSG
     Content string

     //Time at which this message was recieved
     TimeStamp time.Time

     // Entity that this message was addressed to (channel or user)
     To string

     // Nick of the messages sender (equivalent to Prefix.Name)
     // Outdated, please use .Name
     From string
 }

Connection Passing

Hellabot is able to restart without dropping its connection to the server (on Linux machines) by passing the TCP connection through a UNIX domain socket. This allows you to update triggers and other addons without actually logging your bot out of the IRC, avoiding the loss of op status and spamming the channel with constant join/part messages. To do this, run the program again with the same nick and without killing the first program (different nicks wont reuse the same bot instance). The first program will shutdown, and the new one will take over.

This does not work with SSL connections, because we can't hand over a SSL connections state.

Security

Hellabot supports both SSL and SASL for secure connections to whichever server you like. To enable SSL, pass the following option to the NewBot function.

sslOptions := func(bot *hbot.Bot) {
    bot.SSL = true
}

mysslcon, err := hbot.NewBot("irc.freenode.net:6667","hellabot",sslOptions)
// Handle err as you like

mysslcon.Run() # Blocks until disconnect.

To use SASL to authenticate with the server:

saslOption = func(bot *hbot.Bot) {
    bot.SASL = true
    bot.Password = "somepassword"
}

mysslcon, err := hbot.NewBot("irc.freenode.net:6667", "hellabot", saslOption)
// Handle err as you like

mysslcon.Run() # Blocks until disconnect.

Note: SASL does not require SSL but can be used in combination.

Passwords

For servers that require passwords in the initial registration, simply set the Password field of the Bot struct before calling its Start method.

Debugging

Hellabot uses github.com/inconshreveable/log15 for logging. See http://godoc.org/github.com/inconshreveable/log15

By default it discards all logs. In order to see any logs, give it a better handler. Example: This would only show INFO level and above logs, logging to STDOUT

import log "gopkg.in/inconshreveable/log15.v2"

logHandler := log.LvlFilterHandler(log.LvlInfo, log.StdoutHandler)
mybot.Logger.SetHandler(logHandler)

Note: This might be revisited in the future.

Why?

What do you need an IRC bot for you ask? Well, I've gone through the trouble of compiling a list of fun things for you! The following are some of the things hellabot is currently being used for:

  • AutoOp Bot: ops you when you join the channel
  • Stats counting bot: counts how often people talk in a channel
  • Mock users you don't like by repeating what they say
  • Fire a USB dart launcher on a given command
  • Control an MPD radio stream based on chat commands
  • Award praise to people for guessing a random number
  • Scrape news sites for relevant articles and send them to a channel
  • And many other 'fun' things!

References

Client Protocol, RFC 2812 SASL Authentication Documentation

Credits

sorcix for his Message Parsing code

Contributors

  • @whyrusleeping
  • @flexd
  • @Luzifer
  • @mudler
  • @JReyLBC
  • @ForrestWeston
  • @miloprice

More Repositories

1

gx

A package management tool
Go
1,880
star
2

git-ipfs-rehost

A script to rehost your git repos in ipfs
Shell
196
star
3

zmsg

A small program for sending messages via zcash encrypted memo fields
Go
95
star
4

gx-go

gx subtool for golang
Go
80
star
5

ipfs-key

A program to generate ipfs private keys
Go
53
star
6

ipns-pub

a command line tool to publish ipns entries using a passed in private key
Go
50
star
7

cbor-gen

Codegen for cbor codecs on your types
Go
35
star
8

go-tftp

A basic TFTP server and client written in go.
Go
31
star
9

gosky

Some bluesky code
Go
28
star
10

whypfs

IPFS, as nature intended it
Go
27
star
11

pinbot

a bot for the ipfs irc channel that pins things (among other menial tasks)
Go
24
star
12

Neural

My implementation of Neural networks as they are discussed in my AI class.
C++
23
star
13

algoz

Bluesky custom algo hacking
Go
22
star
14

ipfs-counter

A tool to scrape the ipfs network for information on the number of peers in the network.
Go
21
star
15

go-did

Go
19
star
16

toychain

A quick and ugly hack at making a blockchain on ipfs. NOT MAINTAINED
Go
18
star
17

gorocheck

A library to check if unwanted goroutines are still running at the end of a program run or test.
Go
17
star
18

bskybots

Some bot programs for the bluesky network
Go
16
star
19

cbor

Go
13
star
20

rmake

A simple utility that allows building local projects on a remote server.
Go
13
star
21

stackparse

golang stack trace parsing
Go
11
star
22

libp2p-examples

Go
11
star
23

dhtHell

a testing framework for the dht in IPFS
Go
10
star
24

GoLiathChat

Full featured, lightweight chat server and client
Go
10
star
25

go-smux-yamux

yamux implementation of go-stream-muxer
Go
10
star
26

testnet-utils

a set of utilities for testing distributed applications
Shell
10
star
27

natest

A small tool to help check NAT issues
Go
10
star
28

mafmt

[DEPRECATED] Use https://github.com/multiformats/go-multiaddr-fmt
Go
9
star
29

go-pbs

protobuf streams for go
Go
9
star
30

go-netdef

Virtual network creation and management tool using network namespaces
Go
9
star
31

elcid

A cid encoder/decoder tool
Go
9
star
32

zcash-explorer

A simple zcash blockchain explorer UI for ipfs
HTML
8
star
33

libp2p-ios

Trying to make bindings to go-libp2p for iOS
Swift
7
star
34

ipfs-embedded-shell

an implementation of the ipfs-shell interface using an ephemeral node
Go
7
star
35

ipfs-examples

A collection of examples and guides for ipfs
Go
6
star
36

niftyscrape

Go
6
star
37

whysync

a hopefully fast file syncing tool
Go
6
star
38

go-libp2p-pubsub

a basic pubsub for libp2p
Go
6
star
39

p2pdrop

A peer to peer airdrop type app on libp2p
Go
6
star
40

ipfs-network-tests

[DEPRECATED] a set of scripts to run tests on ipfs nodes in a simulated network environment
Go
6
star
41

lua-libp2p

Hacking together a libp2p implementation in lua, for fun, in my copious free time
Lua
6
star
42

hdkeyutils

Tools for working with hierarchically deterministic keys
Go
6
star
43

multireq

the worst piece of code @whyrusleeping has ever written that made it to production
Go
5
star
44

p2pbnch

A small tool to benchmark libp2p transfers
Go
5
star
45

ethtx

simple tool for ethereum transaction generation
Go
5
star
46

ipfs-watcher

A program that produces prometheus metrics for various aspects of the ipfs network
Go
5
star
47

ipcr

A simple tool for encrypting and decrypting files on ipfs
Go
5
star
48

dotfiles

All my important system configuration files, for backup, or for anyone else to browse.
Vim Script
5
star
49

timecache

A time based cache
Go
4
star
50

multiaddr-filter

A library for parsing ip filters and masks in the multiaddr format
Go
4
star
51

gputree

some really ugly gpu code to try and merklize poseidon
C
4
star
52

tar-utils

tar utilities extracted from go-ipfs codebase
Go
4
star
53

ipfs-import-chain

A tool to import data from zcash or bitcoin into ipfs (requires a special ipfs build)
Go
4
star
54

sledge

A simple tool to interface with your ledger
Go
4
star
55

mktx

Some helpers for creating raw bitcoin and zcash transactions
Go
4
star
56

FastGoSkein

A go port of the skein hash function originally written in C from https://github.com/cberner/xkcd_miner. Ive made a few tweaks an optimizations on the original code for added performance.
Go
4
star
57

bases

A simple tool for converting between different base encodings
Go
4
star
58

TinyHtml

An HTML minimizer written in pure Go for use in webserver applications, which by the way, Go is amazing at.
Go
4
star
59

f2

Some scribbles made while writing the fil spec, not maintained
Go
4
star
60

mdfmt

A markdown code block formatter
Go
4
star
61

bencher

A tool to produce a common benchmark output format from go test benchmarks
Go
3
star
62

sleepsort

The super amazing sleep sort. For those of you who want an O(n) sort with no side effects!
Go
3
star
63

sharray

A proposal for an ipld based sharded array
Go
3
star
64

rendaemon

Go
3
star
65

stash

A datastore experiment
Go
3
star
66

gexpin

a pinning service for gx packages
CSS
3
star
67

ghostfs

A distributed, self hosted file system designed for syncing your personal files between devices. This was originally a hackathon project.
Go
3
star
68

query-vis

a tool to visualize ipfs dht queries
Go
3
star
69

json-filter

A library to query json objects marshalled into map[string]interface{}'s
Go
3
star
70

ipfs-webext

demo of running ipfs in a webextension
Shell
3
star
71

ethelp

A helper tool for working with smart contracts
Go
2
star
72

gooey

A simple CLI ui framework in go
Go
2
star
73

p2pc

A netcat like tool for libp2p
Go
2
star
74

GoThreefish

Repackaging of the ThreeFish functions from https://github.com/wernerd/Skein3Fish
Go
2
star
75

GoDHT

My implementation of a distributed hash table in go (of course)
Go
2
star
76

go-sysinfo

a small package to extract system information
Go
2
star
77

paramshare

A stupid simple program for sharing large static files between two points
Go
2
star
78

regtesting

Some basic scripts to set up blockchain regtest environments
Shell
2
star
79

jadb

A toy database project im writing for personal use. jadb stands for "Just Another Database" or "JADB's A Database"
Go
2
star
80

sdl

Golang SDL2 Bindings, Author: qeed
Go
2
star
81

go-smux-multiplex

multiplex implementation of go-stream-muxer
Go
2
star
82

multicast

A multicast library, from scratch, in go
Go
2
star
83

ftp-stress

A stress testing tool for ftp servers
Go
2
star
84

bolt-datastore

A wrapper for boltdb that implements jbenet/go-datastore's Datastore interface
Go
2
star
85

memo

Go
2
star
86

cronus

A Music player app for ipfs
HTML
2
star
87

ipfs-eth-import

A simple tool to help import ethereum data into ipfs
Go
2
star
88

lotus-indexer

Go
2
star
89

abup

Go
2
star
90

base32

base32 encoding package from go with NoPadding option
Go
2
star
91

mss-nc

A netcat like tool to help communicate with multistream servers
Go
2
star
92

netfwd

A very basic port forwarding service
Go
2
star
93

ngrep

A simple tool for grepping network streams
Go
2
star
94

libp2p-bencher

Go
2
star
95

gh-query

A simple tool to help me stay on top of github activity
Go
2
star
96

DissidentGo

A port of Bram Cohen's steganographic library
Go
2
star
97

ipfs-see-all

A tool for viewing all the content of your ipfs nodes repo
Go
2
star
98

go-ctrlnet

Go
2
star
99

arm-sim

A program that can parse and execute armv7 assembly code (tested only on my samsung chromebook).
Go
2
star
100

XmlTool

I had a need for a nice c++ xml library similar to the one built into c#, so i made one.
C++
1
star