Skip to content

Instantly share code, notes, and snippets.

@belak
Last active March 14, 2023 01:48
Show Gist options
  • Save belak/09edcc4f5e51056bf5bc728647659d81 to your computer and use it in GitHub Desktop.
Save belak/09edcc4f5e51056bf5bc728647659d81 to your computer and use it in GitHub Desktop.

Revisions

  1. belak revised this gist Mar 14, 2023. 1 changed file with 11 additions and 4 deletions.
    15 changes: 11 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,18 @@
    # IRC User tracking
    # IRC User Mode Tracking

    Note that this assumes we don't have access to any IRCv3 caps
    This doc includes some random notes on implementing mode/presence tracking
    in IRC. Note that this implementation assumes we don't have access to any
    IRCv3 caps.

    There is a rough implementation for go-irc [here](https://github.com/go-irc/irc/blob/master/tracker.go).

    ## Simple cases

    - MODE - look up the user and channel and modify this mode
    - NICK - rename a user
    - RPL_NAMREPLY (353) - add user to channel and set modes

    ## Single user cases (so, anyone other than the bot itself)
    ## Single user cases (anyone other than the connected user)

    - JOIN - add the user to the channel, creating the user if they aren't tracked
    yet.
    @@ -36,9 +40,12 @@ Note that this assumes we don't have access to any IRCv3 caps
    - A user must be in at least one channel common to the bot, or they will not
    be tracked. This means they can only use privmsg tracking if they are in at
    least one common channel.
    - Modes need to be grabbed from ISUPPORT (005) messages
    - Modes need to be grabbed from ISUPPORT (005) messages - RFC2812 defines 005
    as something else, but this is not how it is used in practice.
    - We don't really know the bot's NICK until the 001 welcome message

    ## CAP notes

    If we can request IRCv3 CAPs, the following make this easier.

    - multi-prefix allows us to get all modes on joining a channel
  2. belak revised this gist Mar 14, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # User tracking
    # IRC User tracking

    Note that this assumes we don't have access to any IRCv3 caps

  3. belak revised this gist Mar 31, 2016. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@ Note that this assumes we don't have access to any IRCv3 caps

    - MODE - look up the user and channel and modify this mode
    - NICK - rename a user
    - RPL_NAMREPLY (353) - add user to channel and set modes

    ## Single user cases (so, anyone other than the bot itself)

    @@ -28,8 +29,6 @@ Note that this assumes we don't have access to any IRCv3 caps

    ## Annoying notes:

    - When a bot joins a channel, we need to look up all users in the channel to
    grab channel modes.
    - Without the multi-prefix CAP, in order to properly track a mode change we
    need to run a NAMES lookup every time a mode changes on a user.
    - There are a number of race conditions, all over the place, mostly around
    @@ -38,4 +37,8 @@ Note that this assumes we don't have access to any IRCv3 caps
    be tracked. This means they can only use privmsg tracking if they are in at
    least one common channel.
    - Modes need to be grabbed from ISUPPORT (005) messages
    - We don't really know the bot's NICK until the 001 welcome message
    - We don't really know the bot's NICK until the 001 welcome message

    ## CAP notes

    - multi-prefix allows us to get all modes on joining a channel
  4. belak revised this gist Mar 31, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -37,4 +37,5 @@ Note that this assumes we don't have access to any IRCv3 caps
    - A user must be in at least one channel common to the bot, or they will not
    be tracked. This means they can only use privmsg tracking if they are in at
    least one common channel.
    - Modes need to be grabbed from ISUPPORT (005) messages
    - Modes need to be grabbed from ISUPPORT (005) messages
    - We don't really know the bot's NICK until the 001 welcome message
  5. belak revised this gist Mar 31, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -36,4 +36,5 @@ Note that this assumes we don't have access to any IRCv3 caps
    private messages.
    - A user must be in at least one channel common to the bot, or they will not
    be tracked. This means they can only use privmsg tracking if they are in at
    least one common channel.
    least one common channel.
    - Modes need to be grabbed from ISUPPORT (005) messages
  6. belak revised this gist Mar 31, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@ Note that this assumes we don't have access to any IRCv3 caps
    ## Simple cases

    - MODE - look up the user and channel and modify this mode
    - NICK - rename a user

    ## Single user cases (so, anyone other than the bot itself)

  7. belak revised this gist Mar 31, 2016. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,31 @@
    * User tracking
    # User tracking

    Note that this assumes we don't have access to any IRCv3 caps

    ** Simple cases
    ## Simple cases

    - MODE - look up the user and channel and modify this mode

    ** Single user cases (so, anyone other than the bot itself)
    ## Single user cases (so, anyone other than the bot itself)

    - JOIN - add the user to the channel, creating the user if they aren't tracked
    yet.
    - PART/KICK - remove the user from a channel, then if they aren't in any other
    tracked channels, remove them.
    - QUIT - remove the user from all channels.

    ** Bot user cases
    ## Bot user cases

    - JOIN - Add the bot to the channel and wait for the RPL_NAMREPLY response
    - PART/KICK - Remove all users from the given channel and run cleanup as needed.
    - QUIT - Pretty much a fatal error.

    ** Useful notes:
    ## Useful notes:

    - When a single user JOINs we don't need to grab modes from anywhere, since
    they should get MODE called on them after joining.

    ** Annoying notes:
    ## Annoying notes:

    - When a bot joins a channel, we need to look up all users in the channel to
    grab channel modes.
    @@ -35,4 +35,4 @@ Note that this assumes we don't have access to any IRCv3 caps
    private messages.
    - A user must be in at least one channel common to the bot, or they will not
    be tracked. This means they can only use privmsg tracking if they are in at
    least one common channel.
    least one common channel.
  8. belak created this gist Mar 31, 2016.
    38 changes: 38 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    * User tracking

    Note that this assumes we don't have access to any IRCv3 caps

    ** Simple cases

    - MODE - look up the user and channel and modify this mode

    ** Single user cases (so, anyone other than the bot itself)

    - JOIN - add the user to the channel, creating the user if they aren't tracked
    yet.
    - PART/KICK - remove the user from a channel, then if they aren't in any other
    tracked channels, remove them.
    - QUIT - remove the user from all channels.

    ** Bot user cases

    - JOIN - Add the bot to the channel and wait for the RPL_NAMREPLY response
    - PART/KICK - Remove all users from the given channel and run cleanup as needed.
    - QUIT - Pretty much a fatal error.

    ** Useful notes:

    - When a single user JOINs we don't need to grab modes from anywhere, since
    they should get MODE called on them after joining.

    ** Annoying notes:

    - When a bot joins a channel, we need to look up all users in the channel to
    grab channel modes.
    - Without the multi-prefix CAP, in order to properly track a mode change we
    need to run a NAMES lookup every time a mode changes on a user.
    - There are a number of race conditions, all over the place, mostly around
    private messages.
    - A user must be in at least one channel common to the bot, or they will not
    be tracked. This means they can only use privmsg tracking if they are in at
    least one common channel.