Help with mIRC chat BOT getting it's own badge info

I have been able to check other users for Mod/Broadcaster status using the below code. However I am having a difficult time figuring out a way to have the ChatBot check it’s own status in a channel.

on friend:TEXT:!role:#:{
  $rolecheck
  if %role = mod {
    /PRIVMSG # $displayname is a $role $+ ! | /unset %role
  }
  elseif %role = broadcaster {
    /PRIVMSG # $displayname is the %role | /unset %role
  }
  else {
    /PRIVMSG # $displayname is a %role $+ ! | /unset %role
  }
}
alias rolecheck {
  if badges=broadcaster/1 isin $msgtags {
    /set %role broadcaster
  }
  elseif user-type=mod isin $msgtags {
    /set %role mod
  }
  else {
    /set %role user
  }
}

I have seen some mention of being able to accomplish what I am trying to do using USERSTATE but I have been unable to find anything to help me understand on how I would get the bot to parse it’s own USERSTATE information.
I have the CAP REQ’s set to trigger when the bot joins a channel as I know that is essential to parsing the info but again I am not seeing a way to have the bot parse it’s own information, just users that do "on *:text:#: commands to trigger it. I did make an attempt at using the “on *:input::#:” as a long shot but that too has not worked. Ultimately I am just wanting to be able to have the Bot check if it is Mod or not in a channel before running certain commands as I have a few friends that would like to make use of the bot in their channels but they want to be able to use it’s non moderation commands when human mods are in chat, and when no Human mods are there, they would Mod the bot and could then use the simple text commands to have the bot perform moderation tasks

This should be done when the bot connects to the server, not on channel join. You’ll get an initial GLOBALUSERSTATE and later on USERSTATEs whenever you join a channel or send a message.

Also note that badges are the way you are meant to parse for these infos via IRC and that they may not necessarily be in the order you expect them to be in - so badges=broadcaster/1 may not be a string that is there, but rather in a later position in the badges list. (For example it may be badges=premium/1,broadcaster/1 - though i have currently not seen anything come before broadcaster.)

Otherwise, you can execute the /mods (or .mods) command to get a list of mods.

Otherwise, it is recommended to use the Get Moderators API Endpoint instead, which requires authentication from the Broadcaster.

An example of incoming messages, prefixed with [CHAT] by my script:

[CHAT] :tmi.twitch.tv CAP * ACK :twitch.tv/membership twitch.tv/tags twitch.tv/commands
[CHAT]
[CHAT] :tmi.twitch.tv 001 redacted :Welcome, GLHF!
[CHAT] :tmi.twitch.tv 002 redacted :Your host is tmi.twitch.tv
[CHAT] :tmi.twitch.tv 003 redacted :This server is rather new
[CHAT] :tmi.twitch.tv 004 redacted :-
[CHAT] :tmi.twitch.tv 375 redacted :-
[CHAT] :tmi.twitch.tv 372 redacted :You are in a maze of twisty passages, all alike.
[CHAT] :tmi.twitch.tv 376 redacted :>
[CHAT] @badge-info=;badges=premium/1;color=#FF69B4;display-name=redacted;emote-sets=redactedforbrevity;user-id=redacted;user-type= :tmi.twitch.tv GLOBALUSERSTATE
[CHAT]
[CHAT] :redacted!redacted@redacted.tmi.twitch.tv JOIN #redacted
[CHAT]
[CHAT] :redacted.tmi.twitch.tv 353 redacted = #redacted :redacted
[CHAT] :redacted.tmi.twitch.tv 366 redacted #redacted :End of /NAMES list
[CHAT] @badge-info=subscriber/23;badges=broadcaster/1,subscriber/3018,premium/1;color=#FF69B4;display-name=redacted;emote-sets=redactedforbrevity;mod=0;subscriber=1;user-type= :tmi.twitch.tv USERSTATE #redacted
[CHAT]
[CHAT] @emote-only=0;followers-only=-1;r9k=0;rituals=0;room-id=redacted;slow=0;subs-only=0 :tmi.twitch.tv ROOMSTATE #redacted
[CHAT]

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