ircstates
rationale
I wanted a bare-bones reference implementation of taking byte input, parsing it into tokens and then managing an IRC client session state from it.
with this library, you can have client session state managed for you and put additional arbitrary functionality on top of it.
usage
simple
import ircstates
server = ircstates.Server("freenode")
lines = server.recv(b":server 001 nick :hello world!\r\n")
lines += server.recv(b":nick JOIN #chan\r\n")
for line in lines:
server.parse_tokens(line)
chan = server.channels["#chan"]
socket to state
import ircstates, irctokens, socket
NICK = "nickname"
CHAN = "#chan"
HOST = "127.0.0.1"
PORT = 6667
server = ircstates.Server("freenode")
sock = socket.socket()
sock.connect((HOST, PORT))
def _send(raw: str):
sock.sendall(f"{raw}\r\n".encode("utf8"))
_send("USER test 0 * test")
_send(f"NICK {NICK}")
while True:
recv_data = sock.recv(1024)
recv_lines = server.recv(recv_data)
for line in recv_lines:
server.parse_tokens(line)
print(f"< {line.format()}")
# user defined behaviors...
if line.command == "PING":
_send(f"PONG :{line.params[0]}")
get a user's channels
>>> server.users
{'nickname': User(nickname='nickname')}
>>> user = server.users["nickname"]
>>> user
User(nickname='nickname')
>>> user.channels
{'#chan'}
get a channel's users
>>> server.channels
{'#chan': Channel(name='#chan')}
>>> channel = server.channels["#chan"]
>>> channel
Channel(name='#chan')
>>> channel.users
{'jess': ChannelUser(#chan jess)}
get a user's modes in channel
>>> channel = server.channels["#chan"]
>>> channel_user = channel.users["nickname"]
>>> channel_user
ChannelUser(#chan jess +ov)
>>> channel_user.modes
{'o', 'v'}
contact
Come say hi at #irctokens on irc.libera.chat
Metadata
Release files for ircstates 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ircstates-0.13.0.tar.gz | 18.3 kB | Without provenance | Details for ircstates-0.13.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ircstates-0.13.0-py3-none-any.whl | Python 3 | none | any | Details for ircstates-0.13.0-py3-none-any.whl |
Total release size: 41.1 kB
Release files / ircstates-0.13.0.tar.gz
| Download URL | ircstates-0.13.0.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d53bf3483b4480f2435475208eb815970941dd59e4473304c553b3ba9b4b3d8b
|
|
BLAKE2b-256 checksum How to use checksums |
1feb838d1e2548ad9367d4e2d6e62ae01f9d812353ab26520437ec181154b819
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / ircstates-0.13.0-py3-none-any.whl
| Download URL | ircstates-0.13.0-py3-none-any.whl |
|---|---|
| Size | 22.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54c8d2a5671f1b572955a0875360a3e5bd45538ab09b60b1444f862cddb5b1be
|
|
BLAKE2b-256 checksum How to use checksums |
b76824468c66d80c42663b383467e8243c12b26edd0a482f812bc7f07a650703
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for ircstates 0.13.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.