Skip to content

Instantly share code, notes, and snippets.

@qpfiffer
Created June 12, 2012 04:38
Show Gist options
  • Select an option

  • Save qpfiffer/2915044 to your computer and use it in GitHub Desktop.

Select an option

Save qpfiffer/2915044 to your computer and use it in GitHub Desktop.
StackBot WIP
#!/usr/bin/python
from irc.client import n_to_nm
import irc.bot
import string
# Stupid definitions:
server = [("kremlin.pncks.com", 6667)]
channel = "#BotTesting"
nickname = "StackBot"
realname = "Jordan"
class StackBot(irc.bot.SingleServerIRCBot):
def __init__(self):
irc.bot.SingleServerIRCBot.__init__(self, server, nickname, realname)
def on_welcome(self, c, e):
c.join(channel)
def on_pubmsg(self, c, e):
if nickname in e.arguments()[0]:
self.do_command(e.arguments()[0])
def on_privmsg(self, c, e):
self.do_command(e.arguments()[0])
def do_command(self, command):
to_lowered = string.lower(command)
print to_lowered
def main():
bot = StackBot()
bot.start()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment