Advertisement
tduva

Simple Twitch IRCv3 tags helper

Sep 15th, 2015
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.67 KB | None | 0 0
  1.  
  2. ; Enable Twitch IRCv3 tags which are required to use identifiers provided in this script
  3. on *:connect:{
  4.   if ($server == tmi.twitch.tv) {
  5.     raw CAP REQ :twitch.tv/tags
  6.   }
  7. }
  8.  
  9. ; All of the following identifiers are to be used in a text event with Twitch IRCv3 message tags
  10.  
  11. ; Checks if a user has been added as a mod in a channel. This may not include the broadcaster
  12. ; and doesn't include global mods, admins or staff.
  13. alias isMod {
  14.   if ($msgtags(user-type).key == mod) {
  15.     return $true
  16.   }
  17.   return $false
  18. }
  19.  
  20. ; Checks for all kinds of mod powers (including broadcaster, global mods, admins and staff).
  21. alias hasModPowers {
  22.   if ($istok(mod global_mod admin staff,$msgtags(user-type).key,32) || $isBroadcaster) {
  23.     return $true
  24.   }
  25.   return $false
  26. }
  27.  
  28. ; Checks if the user is a subscriber in the channel
  29. alias isSub {
  30.   if ($msgtags(subscriber).key == 1) {
  31.     return $true
  32.   }
  33.   return $false
  34. }
  35.  
  36. ; Checks if the user is the broadcaster
  37. alias isBroadcaster {
  38.   if ($chr(35) $+ $nick == $chan) {
  39.     return $true
  40.   }
  41.   return $false
  42. }
  43.  
  44. ; Checks if the user has turbo
  45. alias hasTurbo {
  46.   if ($msgtags(turbo).key == 1) {
  47.     return $true
  48.   }
  49.   return $false
  50. }
  51.  
  52.  
  53. ; Example (just an exmaple on how to use these identifiers)
  54.  
  55. on *:text:!somecommand:#yourchannel:{
  56.   if ($hasModPowers) {
  57.     ;echo -a Do something
  58.   }
  59.   else {
  60.     ;echo -a Don't do something
  61.   }
  62. }
  63.  
  64. ; Testing (output debug message to check that the identifiers work properly)
  65.  
  66. on *:text:*:#cirno_tv:{
  67.   ;twitch_debug
  68. }
  69.  
  70. ; Outputs a debug message
  71. alias -l twitch_debug {
  72.   echo -a Mod: $isMod ModPowers: $hasModPowers Sub: $isSub Broadcaster: $isBroadcaster Turbo: $hasTurbo
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement