Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import irclib
- irclib.DEBUG = True
- import time
- import re
- import search
- network = '' # irc.freenode.net for example
- port = # default is 6667
- nick = ''
- pw = ''
- name = ''
- chanToSay = "#Ghost" # Default chan to stay in
- TRIGGERS = ['!g ', '!w ', '!tv ', '!tss ', '!user ', '!last5 ', '!catte',
- '']
- class Ghost(irclib.SimpleIRCClient):
- """Ghost class extends SimpleIRCClient."""
- def start(self, use_ssl=False):
- """start is a wrapper for self's irclib.ServerConnection.connect()
- The only parameter it accepts is a bool for use_ssl. The rest of
- the parameters should come from the config parser."""
- self.connect(network, port, nick, password=pw, username=name,
- ssl=use_ssl)
- def say(self, thingToSay):
- """thingToSay should be a string for now"""
- self.connection.privmsg(chanToSay, thingToSay)
- def join(self, chan):
- """join chan. chan should be string"""
- self.connection.join(chan)
- def nick(self, nick):
- """change nickname to nick. nick should be string"""
- self.connection.nick(nick)
- def disconnect(self, arg="Exeunt Ghost"):
- """disconnect ghost"""
- self.connection.disconnect(arg)
- def on_pubmsg(self, connection, event):
- msg = ''.join(event.arguments())
- trigs = [re.compile('^' + trig) for trig in TRIGGERS]
- for trig in trigs:
- if trig.match(msg):
- if '!g ' in msg:
- self.say(search.g(msg))
- else:
- self.say("Got it.")
- Zombie = Ghost()
- Zombie.start(use_ssl=True)
- nick = 'Zombie'
- Zombie.nick(nick)
- time.sleep(10)
- Zombie.join(chanToSay)
- Zombie.ircobj.process_forever()
Add Comment
Please, Sign In to add comment