Initial commit.
This commit is contained in:
commit
05b556d024
38 changed files with 6220 additions and 0 deletions
94
scripts/anitv.mrc
Normal file
94
scripts/anitv.mrc
Normal file
|
@ -0,0 +1,94 @@
|
|||
;-- AniTV mIRC Script by prinny
|
||||
;-- Last Modified: 2012-01-11
|
||||
ON *:TEXT:.anitv*:#: {
|
||||
if ($2) {
|
||||
var %url = http://anitv.foolz.us/json.php?controller=search&query= $+ $json.enccomponent($1-) $+ &_timestamp= $+ $ctime
|
||||
var %idx = results
|
||||
}
|
||||
else {
|
||||
var %url = http://anitv.foolz.us/json.php?controller=schedule&total=5&nowplaying=false&_timestamp= $+ $ctime
|
||||
var %idx = programs
|
||||
}
|
||||
|
||||
var %count = $json(%url, %idx).count
|
||||
|
||||
if (%count == 0 && $json(%url, %idx, 0, error) != NULL) {
|
||||
msg $chan Error: $json(%url, %idx, 0, error)
|
||||
}
|
||||
|
||||
if (%count > 10) {
|
||||
var %count = 10
|
||||
}
|
||||
|
||||
var %row = 0
|
||||
while (%row < %count) {
|
||||
var %output = 7 $+ $json(%url,%idx,%row,title) episode 7 $chr(35) $+ $json(%url,%idx,%row,episode) airs on7 $json(%url,%idx,%row,station) at7 $asctime($ctime($json(%url,%idx,%row,airtime)),ddd HH:nn:ss) JST. $chr(91) $+ $+ $replace($duration($calc($json(%url,%idx,%row,unixtime) - $ctime)),secs,s,mins,m,hrs,h,days,d) $+ $+ $chr(93)
|
||||
|
||||
if ($json(%url,%idx,%row,anidb) > 0) {
|
||||
var %output = %output 0- 12 $+ http://anidb.net/a $+ $json(%url,%idx,%row,anidb)
|
||||
}
|
||||
|
||||
msg $chan %output
|
||||
|
||||
inc %row
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
;-- DO NOT EDIT BELOW, THE $json ADDON IS REQUIRED FOR JSON OUTPUT
|
||||
;-- $json by Timi
|
||||
alias json {
|
||||
if ($isid) {
|
||||
var %c = jsonidentifier,%x = 2,%str,%p,%v,%addr
|
||||
|
||||
if ($isfile($1)) { %addr = $qt($replace($1,\,\\,;,\u003b,",\u0022)) }
|
||||
else { %addr = $qt($replace($1,;,\u003b,",\u0022)) }
|
||||
|
||||
json.comcheck
|
||||
if (!$timer(jsonclearcache)) { .timerjsonclearcache -o 0 300 jsonclearcache }
|
||||
|
||||
while (%x <= $0) {
|
||||
%p = $($+($,%x),2)
|
||||
if (%p == $null) { noop }
|
||||
elseif (%p isnum || $qt($noqt(%p)) == %p) { %str = $+(%str,[,%p,]) }
|
||||
else { %str = $+(%str,[",%p,"]) }
|
||||
inc %x
|
||||
}
|
||||
if ($prop == count) { %str = %str $+ .length }
|
||||
|
||||
if ($isfile($1)) {
|
||||
if ($com(%c,eval,1,bstr,$+(str2json,$chr(40),filejson,$chr(40),%addr,$chr(41),$chr(41),%str))) { return $com(%c).result }
|
||||
}
|
||||
elseif (http://* iswm $1 || https://* iswm $1) {
|
||||
if ($com(%c,eval,1,bstr,$+(str2json,$chr(40),urlcache[,%addr,],$chr(41),%str))) { return $com(%c).result }
|
||||
elseif ($com(%c,eval,1,bstr,$+(urlcache[,%addr,]) = $+(httpjson,$chr(40),$qt($1),$chr(41)))) {
|
||||
if ($com(%c,eval,1,bstr,$+(str2json,$chr(40),urlcache[,%addr,],$chr(41),%str))) { return $com(%c).result }
|
||||
}
|
||||
}
|
||||
elseif ($com(%c,eval,1,bstr,$+(x=,%addr,;,x,%str,;))) { return $com(%c).result }
|
||||
}
|
||||
}
|
||||
alias jsonclearcache {
|
||||
if ($com(jsonidentifier)) {
|
||||
if (!$1) { noop $com(jsonidentifier,executestatement,1,bstr,urlcache = {}) }
|
||||
else { echo -a $com(jsonidentifier,executestatement,1,bstr,urlcache[" $+ $1 $+ "] = "") }
|
||||
}
|
||||
}
|
||||
alias json.enc {
|
||||
json.comcheck
|
||||
if ($com(jsonidentifier,eval,1,bstr,encodeURI(" $+ $1- $+ "))) { return $com(jsonidentifier).result }
|
||||
}
|
||||
alias json.enccomponent {
|
||||
json.comcheck
|
||||
if ($com(jsonidentifier,eval,1,bstr,encodeURIComponent(" $+ $1- $+ "))) { return $com(jsonidentifier).result }
|
||||
}
|
||||
alias -l json.comcheck {
|
||||
var %c = jsonidentifier
|
||||
if (!$com(%c)) {
|
||||
.comopen %c MSScriptControl.ScriptControl
|
||||
noop $com(%c,language,4,bstr,jscript) $com(%c,addcode,1,bstr,function httpjson(url) $({,0) y=new ActiveXObject("Microsoft.XMLHTTP");y.open("GET",url,false);y.send();return y.responseText; $(},0))
|
||||
noop $com(%c,addcode,1,bstr,function filejson (file) $({,0) x = new ActiveXObject("Scripting.FileSystemObject"); txt1 = x.OpenTextFile(file,1); txt2 = txt1.ReadAll(); txt1.Close(); return txt2; $(},0))
|
||||
noop $com(%c,addcode,1,bstr,function str2json (json) $({,0) return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(json.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + json + ')'); $(},0))
|
||||
noop $com(%c,addcode,1,bstr,urlcache = {})
|
||||
}
|
||||
}
|
146
scripts/anitv.tcl
Normal file
146
scripts/anitv.tcl
Normal file
|
@ -0,0 +1,146 @@
|
|||
# -----------------------------------------------------------
|
||||
# AniTV Eggdrop/TCL Script
|
||||
# Version : 0.2.0
|
||||
# Updated : 2011.01.11
|
||||
# -- Description --------------------------------------------
|
||||
# Utilizes the AniTV API to display program listings on IRC.
|
||||
# -- Usage --------------------------------------------------
|
||||
# .anitv
|
||||
# .anitv <query>
|
||||
# -- Dependancies -------------------------------------------
|
||||
# + DICT - http://www.tcl.tk/man/tcl/TclCmd/dict.htm
|
||||
# + HTTP - http://tmml.sourceforge.net/doc/tcl/http.html
|
||||
# + JSON - http://tcllib.sourceforge.net/doc/json.html
|
||||
# -- Change Log ---------------------------------------------
|
||||
# @rev 0.2.0 [2012.01.11]
|
||||
# Updated API Calls for AniTV Schedule 0.2.0
|
||||
# @rev 0.1.0 [2011.12.03]
|
||||
# Initial Release
|
||||
# -----------------------------------------------------------
|
||||
|
||||
# Required Packages
|
||||
package require dict;
|
||||
package require http;
|
||||
package require json;
|
||||
|
||||
# Channel Flag
|
||||
setudef flag anitv;
|
||||
|
||||
namespace eval septicore {
|
||||
namespace eval anitv {
|
||||
variable version "septicore-anitv-v0.1";
|
||||
|
||||
bind pub -|- ".anitv" septicore::anitv::display;
|
||||
bind msg -|- ".anitv" septicore::anitv::private;
|
||||
|
||||
proc display { nick host hand chan text } {
|
||||
if { [lsearch -exact [channel info $chan] +anitv] == 1 } { return }
|
||||
|
||||
foreach result [api [join [lrange [split $text] 0 end]]] {
|
||||
output $chan $result;
|
||||
}
|
||||
}
|
||||
|
||||
proc private { nick host hand text } {
|
||||
foreach result [api [join [lrange [split $text] 0 end]]] {
|
||||
output $nick $result;
|
||||
}
|
||||
}
|
||||
|
||||
proc api { search } {
|
||||
set data [list];
|
||||
if { $search == "" } {
|
||||
set url "http://anitv.foolz.us/json.php?controller=schedule&total=5&nowplaying=false";
|
||||
} else {
|
||||
set urlEncodeArg [http::formatQuery query $search];
|
||||
set url "http://anitv.foolz.us/json.php?controller=search&$urlEncodeArg&total=5";
|
||||
}
|
||||
|
||||
set data [http::data [http::geturl $url]];
|
||||
set json_data [::json::json2dict $data];
|
||||
|
||||
if { $json_data == "null" } { return $data; }
|
||||
|
||||
if { $search != "" } {
|
||||
dict with json_data {
|
||||
foreach result $results {
|
||||
if { [dict keys $result "error"] != "" } {
|
||||
dict with result {
|
||||
return [list "Error: $error"];
|
||||
}
|
||||
}
|
||||
|
||||
dict with result {
|
||||
set display "\002\00307$title\003\002 episode \00307#<episode>\003 airs on \00307<station>\003 at \00307<airtime> JST\003. \[\002<eta>\002\]";
|
||||
|
||||
if { $anidb > 0 } {
|
||||
append display " - \037\00312http://anidb.info/a<anidb>\003\037";
|
||||
}
|
||||
|
||||
regsub -- {<episode>} $display $episode display;
|
||||
regsub -- {<subtitle>} $display $subtitle display;
|
||||
regsub -- {<station>} $display $station display;
|
||||
regsub -- {<airtime>} $display $airtime display;
|
||||
regsub -- {<eta>} $display [duration [expr { $unixtime - [unixtime] }]] display;
|
||||
regsub -- {<duration>} $display $duration display;
|
||||
regsub -- {<anidb>} $display $anidb display;
|
||||
|
||||
lappend data $display;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dict with json_data {
|
||||
foreach result $programs {
|
||||
dict with result {
|
||||
set display "\002\00307$title\003\002 episode \00307#<episode>\003 airs on \00307<station>\003 at \00307<airtime> JST\003. \[\002<eta>\002\]";
|
||||
|
||||
if { $anidb > 0 } {
|
||||
append display " - \037\00312http://anidb.info/a<anidb>\003\037";
|
||||
}
|
||||
|
||||
regsub -- {<episode>} $display $episode display;
|
||||
regsub -- {<subtitle>} $display $subtitle display;
|
||||
regsub -- {<station>} $display $station display;
|
||||
regsub -- {<airtime>} $display $airtime display;
|
||||
regsub -- {<eta>} $display [duration [expr { $unixtime - [unixtime] }]] display;
|
||||
regsub -- {<duration>} $display $duration display;
|
||||
regsub -- {<anidb>} $display $anidb display;
|
||||
|
||||
lappend data $display;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
# Default Procs
|
||||
proc notice { dest text } { putquick "NOTICE $dest :$text"; }
|
||||
proc output { dest text } {
|
||||
if { [validchan $dest] && [string first c [lindex [split [getchanmode $dest]] 0]] != -1 } { set text [stripcodes bcruag $text]; }
|
||||
putquick "PRIVMSG $dest :$text";
|
||||
}
|
||||
proc duration { unixtime } {
|
||||
set yrs 0; set wks 0; set days 0; set hrs 0; set min 0; set sec 0; set time "";
|
||||
if { $unixtime < 60 } { return "$unixtime seconds ago" }
|
||||
while { $unixtime >= 31449600 } { incr yrs 1; incr unixtime -31449600 }
|
||||
while { $unixtime >= 604800 } { incr wks 1; incr unixtime -604800 }
|
||||
while { $unixtime >= 86400 } { incr days 1; incr unixtime -86400 }
|
||||
while { $unixtime >= 3600 } { incr hrs 1; incr unixtime -3600 }
|
||||
while { $unixtime >= 60 } { incr min 1; incr unixtime -60 }
|
||||
while { $unixtime > 0 } { incr sec 1; incr unixtime -1 }
|
||||
if { $yrs > 0 } { append time "$yrs\y "; }
|
||||
if { $wks > 0 } { append time "$wks\w "; }
|
||||
if { $days > 0 } { append time "$days\d "; }
|
||||
if { $hrs > 0 } { append time "$hrs\h "; }
|
||||
if { $min > 0 } { append time "$min\m "; }
|
||||
if { $sec > 0 } { append time "$sec\s"; }
|
||||
return $time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
putlog "> Script Loaded: $septicore::anitv::version by TEAM SEPTiCORE";
|
||||
# EOF
|
Loading…
Add table
Add a link
Reference in a new issue