Example #1
0
	def onMessage(self, msg):
		# Call the parent so we still function.
		IrcClient.onMessage(self, msg)
		# Fire off an event for modules to eat
		modules.fire_hook("irc_%s" % msg.command, 
				modules.IrcContext(self, None, msg.origin),
				msg)
Example #2
0
	def onConnected(self):
		IrcClient.onConnected(self)

		if self.user_modes is not None:
			self.sendMessage("MODE", self.nick, self.user_modes)

		modules.fire_hook("connected", self)
		for i in self.channels:
			self.join_channel(i)	
Example #3
0
    def onConnected(self):
        IrcClient.onConnected(self)

        if self.user_modes is not None:
            self.sendMessage("MODE", self.nick, self.user_modes)

        modules.fire_hook("connected", self)
        for i in self.channels:
            self.join_channel(i)
Example #4
0
	def onDisconnected(self):
		modules.fire_hook("disconnected", self)
		IrcClient.onDisconnected(self)
		global connections

		connections -= 1

		if connections == 0:
			self.logger.info("Shutting down.")
			modules.shutdown()
Example #5
0
    def onDisconnected(self):
        modules.fire_hook("disconnected", self)
        IrcClient.onDisconnected(self)
        global connections

        connections -= 1

        if connections == 0:
            self.logger.info("Shutting down.")
            modules.shutdown()
Example #6
0
File: check.py Project: arch2/irc
def run():
    l = logging.getLogger('irc')
    l.setLevel(logging.DEBUG)
    h = logging.StreamHandler()
    h.setLevel(logging.DEBUG)
    l.addHandler(h)
    loop = asyncio.get_event_loop()
    c = IrcClient('irc.freenode.net', 'TulipBot', loop=loop)
    asyncio.Task(c.start())
    loop.run_forever()
Example #7
0
	def __init__(self, network, cfg):

		server = cfg.get("server")
		port = cfg.getint("port")
		nicks = cfg.getlist("nicks")
		ident = cfg.get("ident")
		realname = cfg.get("real name")
        
		def get(opt):
			try:
				return cfg.get(opt)
			except:
				return None



		self._ns_name = get("nickserv name")
		self._ns_pass = get("nickserv password")
		self._ns_find = get("nickserv find")
		ssl = get("ssl")
		serverPassword = get("server password")

		if self._ns_find is None:
			self._ns_find = "is registered"
		
		if self._ns_name is None:
			self._ns_name = "NickServ"

		if self._ns_pass is None:
			self._ns_authed = True
		else:
			self._ns_authed = False

		channels = cfg.getlist("channels")

		IrcClient.__init__(self, server, port, ssl, nicks, ident, realname, serverPassword)

		if channels is None:
			channels = ["#lobby"]

		self.channels = channels


		if network is not None:
			self.network = network
		else:
			self.network = server
		
		self.logger = logging.getLogger("IrcSocket(%s)" % self.network)

		global connections
		connections += 1
Example #8
0
    def __init__(self, network, cfg):

        server = cfg.get("server")
        port = cfg.getint("port")
        nicks = cfg.getlist("nicks")
        ident = cfg.get("ident")
        realname = cfg.get("real name")

        def get(opt):
            try:
                return cfg.get(opt)
            except:
                return None

        self.user_modes = get("user modes")

        self._ns_name = get("nickserv name")
        self._ns_pass = get("nickserv password")
        self._ns_find = get("nickserv find")

        if self._ns_find is None:
            self._ns_find = "is registered"

        if self._ns_name is None:
            self._ns_name = "NickServ"

        if self._ns_pass is None:
            self._ns_authed = True
        else:
            self._ns_authed = False

        channels = cfg.getlist("channels")

        IrcClient.__init__(self, server, port, nicks, ident, realname)

        if channels is None:
            channels = ["#lobby"]

        self.channels = channels

        if network is not None:
            self.network = network
        else:
            self.network = server

        self.logger = logging.getLogger("IrcSocket(%s)" % self.network)

        global connections
        connections += 1
Example #9
0
 def onMessage(self, msg):
     # Call the parent so we still function.
     IrcClient.onMessage(self, msg)
     # Fire off an event for modules to eat
     modules.fire_hook("irc_%s" % msg.command,
                       modules.IrcContext(self, None, msg.origin), msg)
Example #10
0
        channel_ops[channel] = []
    if channel not in channel_voices:
        channel_voices[channel] = []

    if name[:1] == '@':
        channel_ops[channel].append(name[1:])
    elif name[:1] == "+":
        channel_voices[channel].append(name[1:])

def signal_handler(signal, frame):
    irc.quit(quitmessage)
    print ''
    sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)

irc = IrcClient()
joined = False
def on_command_sent(line):
    print "> " + line
irc.set_on_command_sent_callback(on_command_sent)

irc.connect(server, port, nick, realname)

while True:
    s = select.select([irc.socket, sys.stdin], [], [])[0]
    if sys.stdin in s:
        irc.socket.send(sys.stdin.readline().strip() + "\r\n")

    if irc.socket in s:
        line = irc.readline()
        if line is "" or line is None:
Example #11
0
	def onConnected(self):

		IrcClient.onConnected(self)
		modules.fire_hook("connected", self)
		for i in self.channels:
			self.join_channel(i)