Account Tracking: Difference between revisions

From EggWiki
Jump to navigation Jump to search
Line 150: Line 150:


proc acct_op {nick user hand chan text} {
proc acct_op {nick user hand chan text} {
     set accthand [account2hand $nick]
     set accthand [finduser -a [getaccount $nick]]
     if [string match $accthand ""] {
     if [string match $accthand ""] {
       putserv "PRIVMSG $chan :You are not authenticated"
       putserv "PRIVMSG $chan :You are not authenticated"

Revision as of 17:38, 13 July 2022

In Eggdrop version 1.9.3, the ability to identify users based on their IRC service account name was added. However, Eggdrop's ability to 100% accurately track the account name associated with a user on a channel depends on three server-provided features

  • WHOX. WHOX is an updated version of the WHO command that can provide the account name of users in a channel when requested. WHOX allows Eggdrop to obtain the account status of members already present in a channel when it joins. You can view if your IRC server supports WHOX by viewing the 005 line when you connect to the server.
  • Extended-join. Extended-join is an IRCv3 capability that sends the account name of a user (if present) when a user joins a channel. Extended-join allows Eggdrop to obtain the account status of a member as they join a channel. You can view if your IRC server supports this capability by sending /quote CAP LS with your IRC client and viewing the response.
  • Account-notify. Account-notify is an IRCv3 capability that notifies members in a channel when a user authenticates to server. Account-notify allows Eggdrop to update the account status of a user if they authenticate after joining a channel. You can view if your IRC server supports this capability by sending /quote CAP LS with your IRC client and viewing the response.

If these three capabilities are all present and enabled, Eggdrop can accurately track a user's account status at all times. If one or more of these three capabilities is missing, Eggdrop will attempt a "best-effort" at tracking account status based on the information it can glean from the capabilities that are enabled. Additionally, you can negotiate the "account-tag" capability (if the IRC server supports it) and Eggdrop will update the account information of a user that speaks in a channel. For those that like tables, it looks like this:

Eggdrop updates the account list when the... WHOX extended-join account-notify account-tag
... bot joins a channel X
... auth'd user joins a channel X
... user authenticates on a channel X
... auth'd user talks X

Use in Tcl Scripts

The ability to track accounts opens up a wealth of possibilities for Tcl scripts. In order to trigger Tcl script events to cover all instances where a user logs in, it is recommended to pair an ACCOUNT bind with a JOIN bind. This will allow you to check the account (if any) associated with a user as they join, as well as if they authenticate after joining.

Imperfect Tracking

If the WHOX, extended-join and account-notify are not all enabled, the accuracy of the account list looks like this:

WHOX account-notify extended-join account-tag Eggdrop properly tracks a user's account status...
X ... when the bot joins the channel and the user is already authenticated
X X ... when the bot joins the channel and the user is already authenticated, or the user authenticates in a common channel
X X X ... all the time
X X X X ... all the time
X X X ... when the bot joins the channel and the user is already authenticated, or if the user authenticates in a common channel, or an authenticated user joins then talks in a common channel
X X ... when the bot joins the channel and the user is already authenticated, or once an authenticated user talks after joining
X X X ... when the bot joins the channel and the user is already authenticated, or if the user is authenticated before they join a common channel, or once a they join a common channel then authenticate and then talk
X X ... when a user authenticates in a common channel or an already authenticated user joins a channel
X X ... when the bot joins the channel and the user is already authenticated, or an already authenticated user joins a channel
X ... when a user authenticates in a common channel
X X X ... when an authenticated user joins a common channel, or when a user authenticates in the channel, or when a user authenticated before the bot joined talks
X X ... when a user authenticates in a common channel, or a user who authenticated before the bot joined talks
X X .. when an already authenticated user joins the channel or a user who authenticated before the bot joined talks
X ... when an authenticated user joins the channel
X ... when an authenticated user talks

Example Tcl Script

This is an example script that allows an authenticated user to op someone via a public command

bind PUB * .op acct_op

proc acct_op {nick user hand chan text} {
    set accthand [finduser -a [getaccount $nick]]
    if [string match $accthand ""] {
      putserv "PRIVMSG $chan :You are not authenticated"
      return 1
    }
    if {[matchattr $accthand +o|+o $chan]} {
      pushmode $chan +o $text
      putserv "PRIVMSG $chan :Op'ing $nick"
    } else {
      putserv "PRIVMSG $chan :You do not have access to .op"
    }
}

This is an example script that performs actions when a user authenticates or joins a channel already authenticated

bind ACCOUNT * * acct_track_acct
bind JOIN * * acct_track_join

proc acct_track_acct {nick user hand chan acct} {
    if {[string match $acct ""]} {
      putserv "PRIVMSG $chan :$nick de-authenticated"
    } else {
      putserv "PRIVMSG $chan :$nick is now authenticated as $acct"
    }
}

proc acct_track_join {nick user hand chan} {
    set acctnick [getaccount $nick]
    if {[string match $acctnick ""]} {
      putserv "PRIVMSG $chan :$nick joined and is not authenticated."
    } else {
      putserv "PRIVMSG $chan :$nick joined and is authenticated as $acctnick"
    }
}