HalosGhost / ailur

A highly extensible bot written in lua
GNU General Public License v2.0
4 stars 2 forks source link

Improved event handling #40

Open meskarune opened 5 years ago

meskarune commented 5 years ago

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:

local data = irc.connection:receive('*l')
local sender, event, target, message = data:match('^:(%S+) (%w+) (%S+) :?(.*)')

Here is a list of events the bot could potentially react to:

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.

meskarune commented 5 years ago

Will probably need to use LPEG for parsing server messages.

edit: found this https://gist.github.com/jnwhiteh/4b7297414f68b75e7f8d703736a92feb

meskarune commented 4 years ago

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