Created
June 12, 2012 04:38
-
-
Save qpfiffer/2915044 to your computer and use it in GitHub Desktop.
StackBot WIP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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