Skip to main content

No project description provided

Project description


Build Status


example code

import ircstates, irctokens, ircevents, socket

# Connection settings
NICK = "nickname"
HOST = ""
POST = 6667

server = ircstates.Server("freenode")
sock   = socket.socket()
events = ircevents.Engine(sock)

sock.connect((HOST, POST))

def _send(text):
    line = irctokens.tokenise(text)

def _sent(source, state):
    if not state.get("init"):
        state.set("init", True)
        _send(f"USER {NICK} 0 * :{NICK}")
        _send(f"NICK {NICK}")

    while server.pending():
        send_lines = server.sent(source.send(server.pending()))
        for line in send_lines:
            print(f"< {line.format()}")

def _display(line, state):
    print(f"> {line.format()}")

def _ping(line, state)
    _send(f"PONG {line.params[0]}")

def _join(line, state):
    channels = state.get("channels", list())
    for channel in channels:
        if channel not in server.channels:
            _send(f"JOIN {channel}")

    state.set("joined_channels", True)

# Load ircstates as a state mutation
events.use("ircstates", lambda raw: server.recv(raw))

# Events will be received using 1024 bytes from socket
events.recv_with(lambda source, state: source.recv(1024))

# Before processing new data, send queued data to server

# Define what channels to join
events.ns_set("ircstates", "channels", ["#bots", "#test"])

# Run event loop

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ircevents, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size ircevents-0.3.0-py3-none-any.whl (7.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ircevents-0.3.0.tar.gz (5.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page