Simple snipit of code I'm using to make $msgtags easier for mIRC scripts

Hello everyone,

I’ve decided to give my old bots a revamp on their code… Improve on some things. Then I see some things have changed quite a bit on the TwitchTV IRC protocols.

So to make things easier for myself I wrote a little snipit of code that turns the $msgtags into something more usefull.

Below is the code that you can copy and paste into your mIRC bot’s scripts… Anywhere will do really.

alias ttv_getuserinfo {
if ($len($msgtags) < 1) { echo -a * $chr(36) $+ msgtags is not enabled. Type: /CAP REQ :twitch.tv/tags | halt }
var %tags $msgtags
var %total.tags $gettok(%tags,0,59)
var %i 1
while (%i <= %total.tags) {
var %tag. [ $+ [ %i ] ] $gettok(%tags,%i,59)
inc %i 1
}
var %gettag $1
var %j 1
while (%j <= %total.tags) {
var %tag %tag. [ $+ [ %j ] ]
var %attr $gettok(%tag,1,61)
var %value $gettok(%tag,2,61)
if (%attr == $1) { return %value | halt }
else { inc %j 1 }
}
return $false
}

alias ttv_ismod {
if ($ttv_getuserinfo(mod) == 1) { return $true }
else { return $false }
}

alias ttv_issub {
if ($ttv_getuserinfo(subscriber) == 1) { return $true }
else { return $false }
}
alias ttv_isturbo {
if ($ttv_getuserinfo(turbo) == 1) { return $true }
else { return $false }
}
alias ttv_nick {
return $ttv_getuserinfo(display-name)
}
alias ttv_color {
if ($len($ttv_getuserinfo(color)) < 1) { return $false | halt }
return $ttv_getuserinfo(color)
}
alias ttv_usertype {
if ($len($ttv_getuserinfo(user-type)) < 1) { return $false | halt }
return $ttv_getuserinfo(user-type)
}
alias ttv_userid {
if ($len($ttv_getuserinfo(user-id)) < 1) { return $false | halt }
return $ttv_getuserinfo(user-id)
}
alias ttv_roomid {
if ($len($ttv_getuserinfo(room-id)) < 1) { return $false | halt }
return $ttv_getuserinfo(room-id)
}

So essentially you have a few (i forgot what they’re called) variables to choose from:

$ttv_getuserinfo
Syntax: $ttv_getuserinfo(tag)
Returns: Value of matching tag, $false if no matching tag is found.
Example:

on * :text:*:#: { echo -a $ttv_getuserinfo(display-name) }

The other variables are used logically:

$ttv_ismod
Returns: $true of the person is a mod, $false if not
Example:

on * : text : * : # : { if ($ttv_ismod) { echo -a $ttv_nick is a mod } }

$ttv_issub
Same concept as $ttv_ismod except for subscribers

$ttv_isturbo
Same concept as $ttv_ismod except for turbo users.

$ttv_nick
Returns: The display-name of the person talking, $false if empty.
Example: see $ttv_ismod

$ttv_color
Returns: The color the person is using for their display-name, $false if empty.

$ttv_usertype
Returns: The user-type (mod,subscriber,turbo) of the person talking, $false if empty (normal user).

$ttv_userid
Returns: The the person’s (I’m assuming) TwitchTV User ID, $false if empty. (Good for database keys)

$ttv_roomid
Returns: Same concept as User-ID but for rooms.

1 Like

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