mirror of https://github.com/jesopo/irctokens
8bc034241f | ||
---|---|---|
irctokens | ||
test | ||
.gitignore | ||
.travis.yml | ||
LICENSE | ||
README.md | ||
VERSION | ||
setup.py |
README.md
irctokens
rationale
there's far too many IRC client implementations out in the world that do not tokenise data correctly and thus fall victim to things like colons either being where you don't expect them or not being where you expect them.
usage
tokenisation
import irctokens
line = irctokens.tokenise(
"@id=123 :jess!~jess@hostname PRIVMSG #chat :hello there!")
if line.command == "PRIVMSG":
print(f"received message from {line.source}"
f" to {line.params[0]}: {line.params[1]}")
formatting
import sockets
import irctokens
sock = socket.socket()
sock.connect(("127.0.0.1", 6667))
line = irctokens.format("USER", ["user", "0", "*", "real name"])
to_send = "%s\r\n" % line
sock.send(to_send.encode("utf8"))