Using $msgtags(display-name).key in mIRC

Right now, I’ve got a text command for my bot which just responds to the command with a simple message which includes the display name of the person using the command. So to retrieve the display name of said person, I’m using $msgtags(display-name).key but I was just wondering if there were any instances of this ever not working? It’s worked fine for pretty much everyone I’ve encountered so far, however one person (who hasn’t changed their name or modified their display name) it just appears as a blank space and doesn’t retrieve their name. Just wondering if there would be a cause for this, thanks.

I don’t think it’s guaranteed that all users will have a display name in the tags. So you should check if the tag exists and is non-empty, and otherwise just use $nick. You could even make an identifier for this, so you just need to write $displaynick or something in the actual command response.

2 Likes

Yeah, his name turned out to have something going on with it – his chat name had a capitalised first letter, however BTTV showed it as all lowercase whenever I was highlighted by him. I got him to check his display name in his Twitch settings and that was all lowercase too, but his display name in chat still had that capitalised first letter. I guessed that it probably had something to do with when he created his account (back in 2010) and Twitch may have automatically capitalised the first letter of all names before implementing the display name option. Anyway, after he modified his name in the display name box in his settings, it started working. Thanks!

If he never set his display name, it may not have the display-name tag, which means that it depends on the chat client on how to display it. Some do it all lowercase, some capitalize the first letter.

1 Like

@tduva is correct. According to the Chat and IRC documentation, if the user never went into their settings and customized their name display, it could be empty. You can implement display-name but as a fail safe, include their normal username.

2 Likes

Consider this example:

a user signs up for twitch
they choose their username as barrycarlyon

When they are drawn in chat, their nick is barrycarlyon Twitch Chat will generally render the first letter of a name is as capital Barrycarlyon IRC will render as all lowercase, the chatters endpoint I believe will capitalise first letter also without a display_name having been set.

Since this user has not set a display name, then their display_name in tags will be blank (or in some cases depending on your parser evaluate to TRUE

So

  • nick barrycarlyon
  • drawn Barrycarlyon
  • tags BLANK

Only when a user has set there display name in settings (or even just saved the first page) then and only then will display name in tags be populated with the correct name

So

  • nick barrycarlyon
  • drawn BarryCarlyon
  • tags BarryCarlyon

I run something like:

name = (display_name && display_name !== TRUE) ? display_name : nick

as my parser evals a blank tag to TRUE :stuck_out_tongue:

1 Like
alias displayname {
  if ($msgtags(display-name).key !== $null) {
    return $v1
  }
  return $nick
}

;; example
on *:TEXT:!trigger:#somechannel:{
  msg #somechannel Thanks $displayname for using my trigger
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.