Skip to content
Browse files

- Added "commands" and "help" commands

- Added notices after an op uses !learn !forget or !replace
- Made the dictionary case insensitive
  • Loading branch information...
1 parent e71dd2a commit 3b593e813e11903e497277b80084f33a6d0fab7e @nibroc committed Jul 24, 2011
Showing with 30 additions and 6 deletions.
  1. +30 −6 voicebot.py
View
36 voicebot.py
@@ -1,3 +1,4 @@
+#!/usr/bin/python
"""
VoiceBot...
@@ -22,9 +23,9 @@
DEBUG_OUTPUT = len(argv) > 1 and argv[1] == "output"
CONFIG = {
- "nick": "VoiceBot",
+ "nick": "VoiceBot2",
"channel": "#somechannel",
- "server": ("someserver", 6667),
+ "server": ("my.pony.com.es", 6667),
"user": {
"username": "VoiceBot",
"hostname": "voice.bot",
@@ -240,6 +241,25 @@ def parsemsg(s):
activelyVoicing = True
f.write("PRIVMSG %s :%s\n" % (msgNick, "Will voice"))
f.flush()
+ elif msg == "commands":
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "commands: voiceme, blockvoice, unblockvoice, raw, stopvoice, killvoice, startvoice, debug, !learn, !forget, !replace"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "For a more detailed list, use 'help'"))
+ f.flush()
+ elif msg == "help":
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "-----Private message commands-----"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "voiceme - Voices the messager unless [s]he is on the ignore list"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "blockvoice [nickList] - adds 1 or more nicks to the block list (space separated list of nicks)"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "unblockvoice [nickList] - removes 1 or more nicks from the block list (space separated list of nicks)"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "raw [line] - has the bot send the line to the server (ex: raw PRIVMSG #channel :I can talk!)"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "stopvoice - tells the bot to no longer voice when people join"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "killvoice - tells the bot to no longer voice when people join, and removes voice from anyone to whom it has been given"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "startvoice - tells the bot to start voicing again (note: at this time, it not automatically regiven to people from whom it was removed with killvoice)"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "debug - Prints out a few debugging things, such as which users are voiced blocked and whether the bot is voicing"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "-----Channel commands-----"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "!learn [key] [definition]"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "!replace [key] [newDefinition]"))
+ f.write("PRIVMSG %s :%s\n" % (msgNick, "!forget [key]"))
+ f.flush()
else:
# Message to a channel
@@ -251,21 +271,25 @@ def parsemsg(s):
if (msg.find("!learn ") == 0 or msg.find("!replace ") == 0) and msgNick.lower() in opNicks:
sp = msg.split(' ')
if(len(sp) >= 3):
- key = sp[1]
+ key = sp[1].lower()
val = ' '.join(sp[2:])
learned[key] = val
flushLearned = True
+ f.write("NOTICE %s :%s\n" % (msgNick, "Learned"))
+ f.flush()
elif msg.find("!forget ") == 0 and msgNick.lower() in opNicks:
- key = msg[len("!forget "):]
+ key = msg[len("!forget "):].lower()
if learned.has_key(key):
del learned[key]
flushLearned = True
+ f.write("NOTICE %s :%s\n" % (msgNick, "Forgotten"))
+ f.flush()
elif msg.find("? ") == 0:
key = msg[len("? "):]
- if learned.has_key(key):
- f.write("PRIVMSG %s :%s\n" % (target, "\x02%s\x02: %s" % (key, learned[key])))
+ if learned.has_key(key.lower()):
+ f.write("PRIVMSG %s :%s\n" % (target, "\x02%s\x02: %s" % (key, learned[key.lower()])))
else:
f.write("PRIVMSG %s :%s\n" % (target, "I don't know \x02%s\x02" % key))

0 comments on commit 3b593e8

Please sign in to comment.
Something went wrong with that request. Please try again.