X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/b5e5c4470d993b41113ae43b7f5030d412585430..52c80cff91dce5fa14ae903c6c2bf20533ccca46:/modules/sockets.py diff --git a/modules/sockets.py b/modules/sockets.py index 060057b..f9577e1 100644 --- a/modules/sockets.py +++ b/modules/sockets.py @@ -1,9 +1,34 @@ # Erebus IRC bot - Author: Erebus Team # vim: fileencoding=utf-8 +# Configurable sockets module. DO NOT USE without understanding the risks # This file is released into the public domain; see http://unlicense.org/ # Note: this module doesn't do any kind of authentication, so anyone who can connect to the bound port can spam you. +""" +To use - add in bot.config something like: + +[sockets] +127.0.0.1:1337 = #example + +The left side is the address to listen on and the right side is the channel to send to. +The exmaple will send incoming lines/packets on localhost, port 1337 to channel #example + +The full syntax for the address is: +[unix:] +[udp|tcp:][:] + + +Address examples: + +Unix domain socket: /path +Unix domain socket: unix:/path +TCP socket (all interfaces): 1337 +TCP socket (one interface): 127.0.0.1:1337 +UDP socket (all interfaces): udp:1337 +UDP socket (one interface): udp:127.0.0.1:1337 +""" + # module info modinfo = { 'author': 'Erebus Team', @@ -57,7 +82,10 @@ def gotParent(parent): return lines def parse(self, line): - bot = lib.parent.randbot() + try: + bot = lib.parent.channel(self.chan).bot + except AttributeError: # 'NoneType' object has no attribute 'bot' + bot = lib.parent.randbot() maxlen = bot.maxmsglen() - len("PRIVMSG :") - len(self.chan) while len(line) > maxlen: cutat = line.rfind(' ', 0, maxlen)