Open meskarune opened 5 years ago
Will probably need to use LPEG for parsing server messages.
edit: found this https://gist.github.com/jnwhiteh/4b7297414f68b75e7f8d703736a92feb
Prosody is an xmpp server written in lua. They have some code they use for event handling that might be useful to look at: https://hg.prosody.im/trunk/file/tip/util/events.lua
This lua irc bot uses a message queue: https://github.com/ShadowNinja/LuaIRC/blob/4324f5627e8918325e4071b91cee3017d98c7c80/main.lua#L176
Adding support for handling of other IRC events outside privmsg.
Majority of events come in the format
:source event target tags :message
but tags and message is not always present.https://ircv3.net/specs/extensions/message-tags.html
ie:
:nick!ident@host PRIVMSG ##test :hello there
This would catch the majority of events but could be improved:
Here is a list of events the bot could potentially react to:
PRIVMSG <target> :<either CTCPByteString or text>
NOTICE <target> :<either CTCPByteString or text>
NICK <nickname>
JOIN <channel>
PART <channel> :<text>
QUIT :<text>
MODE <target> <mode flags>
TOPIC <channel> :<text>
INVITE <channel> <botnick>
KICK <channel> <nick> :<text>
PING <server>
<numeric int> <target> <tags> :<message>
List of IRC server numeric replies: https://www.alien.net.au/irc/irc2numerics.html
There is also a yaml file: https://gist.github.com/proxypoke/2264878
This perl lib has all the numeric responses in an array: https://metacpan.org/source/APEIRON/Net-IRC-0.79/Event.pm#L201 It seems like most IRC libs in python do the same and basically took the idea from net::irc ie: https://github.com/jaraco/irc/blob/master/irc/events.py
List of major clients and what IRC features they handle: https://ircv3.net/software/clients.html
Sorry for the info dump. I thought it might be useful to throw events and links all in one spot.
There should be some decision made about what events to even handle. I would suggest handling some numeric events like "nick name in use" so the bot can use a fallback nickname and ghost it's own nickname when needed. I don't think it's necessary to have complete support for all of ircv3.