version: 0000.0000.0006
I've moved this project to github in hopes of alleviating some of the headaches caused by maintaining 5+ pages for what is essentially the same project. I also hope the move will motivate others to get involved and contribute to the codebase
This is the core in which all of my mTwitch normalizing scripts depend on
on *:START:{
if (!$JSONVersion) {
echo $color(info2) -a [mTwitch->Core] This script depends on SReject's JSON parser to be loaded
.timer 1 0 .unload -rs $qt($script)
return
}
mTwitch.chatServerListUpdate
}
on *:UNLOAD:{
.timermTwitch.chatServerListUpdate off
}
raw 004:*:{
if ($mTwitch.isServer()) {
.parseline -iqptu0 :tmi.twitch.tv 005 $me NETWORK= $+ $iif($mTwitch.isServer().isGroup, groupchat.,) $+ twitch.tv :are supported by this server
}
}
alias mTwitch.isServer {
if (!$isid) {
return
}
if (!$JSONVersion) {
echo $color(info2) -a [mTwitch->Core] This script depends on SReject's JSON parser to be loaded
.timer 1 0 .unload -rs $qt($script)
return
}
if (!$hget(mTwitch.chatServerList) || !$timer(mTwitch.chatServerListUpdate)) {
mTwitch.chatServerListUpdate
}
if (!$len($1-)) {
tokenize 32 $server
}
if (!$0) {
return $false
}
if (!$prop) && ($network === twitch.tv || $1- == tmi.twitch.tv || $1- == irc.twitch.tv) {
return $true
}
elseif ($prop == isGroup && $network == groupchat.twitch.tv) {
return $true
}
if (!$longip($1)) {
return $false
}
if ($hget(mTwitch.chatServerList, $1)) {
var %type = $v1
if (!$prop || ($prop == isGroup && %type == group)) {
return $true
}
}
return $false
}
alias mTwitch.chatServerListUpdate {
if ($isid || !$JSONVersion) {
return
}
var %i = 0, %e, %ii = 0, %ee, %s, %n = mTwitch_getChatServerList, %nn = mTwitch_getGroupServerList, %h = mTwitch.chatServerList
JSONOpen -ud %n http://api.twitch.tv/api/channels/SReject/chat_properties
if ($JSONError) {
return
}
%e = $JSON(%n, chat_servers, length)
if (!%e || $JSONError) {
return
}
JSONOpen -ud %nn http://tmi.twitch.tv/servers?cluster=group
if ($JSONError) {
return
}
%ee = $JSON(%nn, servers, length)
if (!%ee || $JSONError) {
return
}
if ($hget(%h)) {
hfree $v1
}
while (%i < %e) {
hadd -m %h $gettok($JSON(%n, chat_servers, %i), 1, 58) General
inc %i
}
while (%ii < %ee) {
hadd -m %h $gettok($JSON(%nn, servers, %ii), 1, 58) Group
inc %ii
}
.timermTwitch.chatServerListUpdate -io 1 3600 mTwitch.chatServerListUpdate
}
alias mTwitch.has.core return 0000.0000.0006
v0.0.0006:
$network
is now filled withgroupchat.twitch.tv
for group chat servers
v0.0.0005: Added better environment checking
v0.0.0004: Added 005 token injection;$network
is now filled withtwitch.tv
for twitch servers
v0.0.0003: Fixed$mTwitch.isServer()
returning$false
for twitch servers
v0.0.0002: Addedon Unload
event