summaryrefslogtreecommitdiff
path: root/modules/quotes.py
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2009-11-14 01:28:23 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2009-11-14 01:28:23 +0100
commitdcebcafcc52ae847077890b551b8319d80d36d91 (patch)
tree1496e0436e56a8076891ed6be551004c59d32c13 /modules/quotes.py
A much needed inital import.
Diffstat (limited to 'modules/quotes.py')
-rw-r--r--modules/quotes.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/quotes.py b/modules/quotes.py
new file mode 100644
index 0000000..b8eb988
--- /dev/null
+++ b/modules/quotes.py
@@ -0,0 +1,33 @@
+info = {
+ 'author': 'Jon Bergli Heier',
+ 'title': 'IRC Quotes',
+ 'description': 'Allows users to access a quote database.',
+}
+
+import sys
+sys.path.insert(0, '/home/snakebite/py')
+from quotelib import IRCHandler as Quote_IRCHandler
+quote_handler = Quote_IRCHandler('/home/snakebite/quotes.db')
+
+class Module:
+ def __init__(self, bot):
+ self.irc = bot
+
+ def __call__(self, nick, channel, msg):
+ if not msg.startswith('!quote'):
+ return
+ args = msg.split(' ')
+ if msg.startswith('!quote'):
+ args = args[1:]
+ cmd = args[0] if len(args) and len(args[0].strip()) else 'random'
+ args = args[1:]
+
+ if cmd.isdigit() or (cmd[0] == '#' and cmd[1:].isdigit()):
+ cmd, args = 'get', [cmd]
+
+ quote_handler.nick = nick.split('!')[0]
+ if hasattr(quote_handler, cmd) and callable(getattr(quote_handler, cmd)):
+ for line in getattr(quote_handler, cmd)(*args):
+ self.irc.msg(channel if not channel == self.irc.nickname else nick.split('!')[0], line)
+ else:
+ self.irc.msg(channel if not channel == self.irc.nickname else nick.split('!')[0], '%s, invalid command "%s"' % (nick.split('!')[0], cmd))