Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
irc.json

17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,19 @@ A Cards Against Humanity IRC bot

This is currently a very poorly written bot, however most of the functionality is complete.

Future versions will focus on making it easier for users to run their own version, simply by editing a json file containing any options that are required.
Future versions will focus on making it easier for users to run their own
version, simply by editing a json file containing any options that are required.

Configuration file
------------------

Simply copy the content of the ``irc-sample.json`` file provided and save it as ``irc.json``. Adapt it to your needs. You can provide the following keys:

* host
* port
* channel
* identity
* realname
* hostname
* botname
* password
5 changes: 5 additions & 0 deletions irc-sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[{
"host": "irc.freenode.org",
"port": 6667,
"channel": "#brunobordtest"
}]
34 changes: 17 additions & 17 deletions sprbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
from datetime import timedelta
import select
import functions
import json


class IRCConnector( threading.Thread):
def __init__ (self, host, port):
self.host = host
self.port = port
self.channel = "#cah"
self.identity = "superbot"
self.realname = "superbot"
self.hostname = "supermatt.net"
self.botname = "humanitybot"
def __init__ (self, config):
self.host = config.get('host')
self.port = config.get('port')
self.channel = config.get('channel', "#cah")
self.identity = config.get("identity", "superbot")
self.realname = config.get("realname", "superbot")
self.hostname = config.get("hostname", "supermatt.net")
self.botname = config.get('botname', "humanitybot")
self.password = config.get('password', 'hum4n1ty')
self.allmessages = []
self.lastmessage = datetime.now()
self.pulsetime = 500
Expand Down Expand Up @@ -74,7 +77,7 @@ def run (self):
if re.search(":End of /MOTD command.", line):
joinchannel = "JOIN %s\n" %self.channel
self.output(joinchannel)
self.s.send("PRIVMSG nickserv :identify hum4n1ty\n")
self.s.send("PRIVMSG nickserv :identify %s\n" % self.password)
self.s.send(joinchannel)
self.inchannel = True

Expand Down Expand Up @@ -140,12 +143,9 @@ def run (self):
#print self.allmessages


irc_connections = [{
"host": "irc.darkmyst.org",
"port": 6667,
"channels": ["#cah"]
}]
if __name__ == '__main__':
irc_connections = json.load(open('irc.json'))

for irc in irc_connections:
IRCThread = IRCConnector(irc['host'], irc['port'])
IRCThread.start()
for config in irc_connections:
IRCThread = IRCConnector(config)
IRCThread.start()