Created
December 29, 2011 23:46
-
-
Save bmn/1536742 to your computer and use it in GitHub Desktop.
A set of functions for mIRC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Add this script to remote.ini in the mIRC script editor, or load it as a remote script. | |
; These functions only run if the channel is on a Justin.tv server, and you are a mod in that channel. | |
; You also need JSON and SQLite plugins for mIRC, both of which should be loaded as remote scripts: | |
; http://www.mircscripts.org/comments.php?cid=4407 | |
; http://www.mirc.net/projects.php?go=1155286814 | |
; REMOTES | |
on *:START:{ | |
; shorten db | |
set %db $sqlite_open(sqlite.db) | |
if (!%db) { | |
echo [DB] Failed to connect to DB: %sqlite_errstr | |
return | |
} | |
else { | |
sqlite_exec %db CREATE TABLE IF NOT EXISTS "shorten" ("url" VARCHAR PRIMARY KEY NOT NULL UNIQUE, "target" VARCHAR, "updated" INTEGER) | |
echo [DB] Connected to DB. | |
} | |
; spam | |
hmake spam 10 | |
hadd spam dshini http:\/\/(?:www\.)?dshini\.net\/de\/spage\/ | |
hadd spam ihatelola http:\/\/(?:www\.)?ihatelola\.com\/\?id= | |
hadd spam ultras http:\/\/(?:www\.)?ultrasonline2?\.com | |
hadd spam mspoints http:\/\/(?:www\.)?mspointscodes\.com\/\?i= | |
hadd spam joliecindy http:\/\/(?:www\.)?joliecindy\.com\/\?id= | |
echo [SPAM] Created spam hash. | |
} | |
; spam links | |
ON *:TEXT:*dshini.net/de/spage/*:*: spam dshini $1- | |
ON *:TEXT:*ihatelola.com*:*: spam ihatelola $1- | |
ON *:TEXT:*ultrasonline*.com*:*: spam ultras $1- | |
ON *:TEXT:*mspointscodes.com*:*: spam mspoints $1- | |
ON *:TEXT:*joliecindy.com*:*: spam joliecindy $1- | |
; youtube | |
ON *:TEXT:*youtube.com/watch?*:*: youtube $1- | |
ON *:TEXT:*youtu.be/*:*: youtube $1- | |
; Justin | |
ON *:TEXT:*justin.tv/*/b/*:*: justin $1- | |
ON *:TEXT:*twitch.tv/*/b/*:*: justin $1- | |
; shorten links | |
ON *:TEXT:*bit.ly/*:*: shorten bitly http:\/\/(?:www\.)?bit.ly\/([A-Za-z0-9]+) $1- | |
ON *:TEXT:*tinyurl.com/*:*: shorten TinyURL http:\/\/(?:www\.)?tinyurl\.com\/([a-zA-Z0-9_-]+) $1- | |
ON *:TEXT:*is.gd/*:*: shorten is.gd http:\/\/(?:www\.)?is\.gd\/([a-zA-Z0-9_-]+) $1- | |
; ALIASES | |
; $is_justin_serv => bool | |
; Returns whether you're on the Justin server | |
alias is_justin_serv return $iif($server == irc.justin.tv, $true, $false) | |
; $is_justin_mod => bool | |
; Returns whether you're an op in the current channel | |
alias is_justin_mod return $iif(($is_justin_serv) && ($me isop $chan), $true, $false) | |
alias youtube { | |
if (!$is_justin_mod) halt | |
if (!$regex($1-,/(youtube\.com\/watch\?(?:[^ ]+&)?v=|youtu.be\/)([a-zA-Z0-9_-]+)/)) halt | |
echo jtv $time $+ : $1- | |
var %j = $json.enc(http://gdata.youtube.com/feeds/api/videos/ $+ $regml(2) $+ ?v=2&alt=jsonc) | |
if ($json(%j,error,code)) { | |
var %out = [YT] $json(%j,error,code) $json(%j,error,message) | |
msg $chan %out | |
echo jtv %out | |
halt | |
} | |
var %out = [YT] $json(%j,data,uploader) $+ : " $+ $json(%j,data,title) $+ " | |
msg $chan %out | |
echo jtv %out | |
} | |
alias justin { | |
if (!$is_justin_mod) halt | |
if (!$regex($1-,/(justin|twitch)\.tv\/([\w_-]+)\/b\/(\d+)/)) halt | |
echo jtv $time $+ : $1- | |
var %j = $json.enc(http://api.justin.tv/api/clip/show/ $+ $regml(3) $+ .json) | |
var %t = $json(%j,0,title) | |
if (%t) %t = " $+ %t $+ " | |
else %t = Untitled | |
var %out = [JTV] %t [DL] $json(%j,0,video_file_url) | |
msg $chan %out | |
echo jtv %out | |
} | |
alias spam { | |
if (!$is_justin_mod) return 0 | |
if ($1 == all) { | |
var %i = 1, %ct = $hget(spam,0).Item | |
while (%i <= %ct) { | |
if ($regex($2-,/ $+ $hget(spam,%i).Data $+ /i)) { | |
echo $time $+ : $1- | |
ban $hget(spam,%i).Item | |
return 1 | |
} | |
inc %i | |
} | |
} | |
elseif ($regex($2-,/ $+ $hget(spam,$1) $+ /i)) { | |
echo $time $+ : $1- | |
ban $1 | |
return 1 | |
} | |
return 0 | |
} | |
alias shorten { | |
var %u, %q, %o | |
if (!%db) { return } | |
if (!$is_justin_mod) halt | |
if (!$regex($3-,/( $+ $2 $+ )/)) halt | |
%o = $regml(1) | |
echo $time $+ : $1- | |
; try to find it in the db first | |
%q = SELECT * FROM shorten WHERE url=' $+ $sqlite_escape_string(%o) $+ ' | |
var %r = $sqlite_query(%db,%q) | |
if (!%r) { | |
echo 4 -a Error: %sqlite_errstr | |
return | |
} | |
if ($sqlite_num_rows(%r)) { | |
sqlite_fetch_row %r row | |
var %ud = $ctime - 600 | |
echo Updated $hget(row,updated) & 10 mins ago is %ud | |
if ($hget(row,updated) < %ud) { | |
%q = DELETE FROM shorten WHERE url=' $+ $sqlite_escape_string(%o) $+ ' | |
sqlite_exec %db %q | |
echo Deleted %o | |
} | |
else { | |
%u = $hget(row,target) | |
echo Found %o > %u in DB | |
} | |
} | |
sqlite_free %r | |
; use the api | |
if (!%u) { | |
var %j = http://api.longurl.org/v2/expand?url= $+ $json.enccomponent(%o) $+ &format=json | |
var %u = $json(%j,long-url) | |
echo Found %j > %u from API | |
%q = INSERT INTO shorten (url, target, updated) VALUES (' $+ $sqlite_escape_string(%o) $+ ',' $+ $sqlite_escape_string(%u) $+ ', $ctime $+ ) | |
sqlite_exec %db %q | |
echo Inserted %o | |
} | |
if ($spam(all,%u)) halt | |
msg $chan $chr(91) $+ $1 $+ $chr(93) $iif(%u == %o,Invalid URL,%u) | |
} | |
alias ban { | |
if (!$is_justin_mod) halt | |
echo jtv .ban $nick | |
msg $chan .ban $nick | |
msg $chan $iif($1,$chr(91) $+ $1 $+ $chr(93)) $random_select(g'day mate,take it,wtf man,see ya nerd,this $nick kid) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment