tduva icon

Simple Twitch IRCv3 tags helper

tduva | PRO | 09/15/15 11:43:58 PM UTC | 0 ⭐ | 1009 👁️ | Never ⏰ | []
mIRC |

1.67 KB

|

None

|

0 👍

/

0 👎

 
; Enable Twitch IRCv3 tags which are required to use identifiers provided in this script
on *:connect:{
  if ($server == tmi.twitch.tv) {
    raw CAP REQ :twitch.tv/tags
  }
}
 
; All of the following identifiers are to be used in a text event with Twitch IRCv3 message tags
 
; Checks if a user has been added as a mod in a channel. This may not include the broadcaster
; and doesn't include global mods, admins or staff.
alias isMod {
  if ($msgtags(user-type).key == mod) {
    return $true
  }
  return $false
}
 
; Checks for all kinds of mod powers (including broadcaster, global mods, admins and staff).
alias hasModPowers {
  if ($istok(mod global_mod admin staff,$msgtags(user-type).key,32) || $isBroadcaster) {
    return $true
  }
  return $false
}
 
; Checks if the user is a subscriber in the channel
alias isSub {
  if ($msgtags(subscriber).key == 1) {
    return $true
  }
  return $false
}
 
; Checks if the user is the broadcaster
alias isBroadcaster {
  if ($chr(35) $+ $nick == $chan) {
    return $true
  }
  return $false
}
 
; Checks if the user has turbo
alias hasTurbo {
  if ($msgtags(turbo).key == 1) {
    return $true
  }
  return $false
}
 
 
; Example (just an exmaple on how to use these identifiers)
 
on *:text:!somecommand:#yourchannel:{
  if ($hasModPowers) {
    ;echo -a Do something
  }
  else {
    ;echo -a Don't do something
  }
}
 
; Testing (output debug message to check that the identifiers work properly)
 
on *:text:*:#cirno_tv:{
  ;twitch_debug
}
 
; Outputs a debug message
alias -l twitch_debug {
  echo -a Mod: $isMod ModPowers: $hasModPowers Sub: $isSub Broadcaster: $isBroadcaster Turbo: $hasTurbo
}

Comments