No project description provided
Project description
ircevents
usage
example code
import ircstates, ircevents, socket
# Connection settings
NICK = "nickname"
CHAN = "#chan"
HOST = "127.0.0.1"
POST = 6667
server = ircstates.Server("freenode")
sock = socket.socket()
events = ircevents.Engine(sock)
sock.connect((HOST, POST))
def _send(text):
line = irctokens.tokenise(text)
server.send(line)
def _sent(s):
while server.pending():
send_lines = server.sent(s.send(server.pending()))
for line in send_lines:
print(f"> {line.format()}")
@events.when(_always=True)
def _display(line, state):
print(f"> {line.format()}")
@events.when(command="001")
def _join(line, state):
channels = state.get("channels", list())
for channel in channels:
if channel not in server.channels:
_send(f"JOIN {channel}")
_send("USER test 0 * :test")
_send("NICK test321")
# 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 s: s.recv(1024))
# Before processing new data, send queued data to server
events.pre_process(_sent)
# Define what channels to join
events.ns_set("ircstates", "channels", ["#bots", "#test"])
# Run event loop
events.run()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ircevents-0.1.1.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for ircevents-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 077f808bd7308e2d39470723859c74cc74eafaa12aaf189282ba570e4e9855e0 |
|
MD5 | a5c55c48abc09925ebbc2b0e01c9c7fa |
|
BLAKE2b-256 | 3c3e3395dc7086193fadc75690f77c677adfab33214a006d481d13a99261e519 |