Go to file
jesopo 934a901ba1 v0.2.2 release 2020-03-11 14:37:31 +00:00
irctokens fix _escape_tag typehint issue 2020-03-11 13:44:44 +00:00
test add tests for Line formatting 2020-03-11 13:43:13 +00:00
.gitignore Initial commit 2020-03-11 11:26:13 +00:00
.travis.yml add test.format to .travis.yml 2020-03-11 14:07:19 +00:00
LICENSE Initial commit 2020-03-11 11:26:13 +00:00
README.md fix README.md "import sockets" typo 2020-03-11 13:55:41 +00:00
VERSION v0.2.2 release 2020-03-11 14:37:31 +00:00
setup.py fix setup.py minimum python version (fstrings needs 3.6) 2020-03-11 14:15:21 +00:00

README.md

irctokens

Build Status

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 socket
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"))