Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved event handling #40

Open
meskarune opened this issue Apr 2, 2019 · 2 comments
Open

Improved event handling #40

meskarune opened this issue Apr 2, 2019 · 2 comments

Comments

@meskarune
Copy link
Collaborator

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:

  • 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.

@meskarune
Copy link
Collaborator Author

meskarune commented Jun 5, 2019

Will probably need to use LPEG for parsing server messages.

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

@meskarune
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant