summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--lib/Multi/IRC.pm28
2 files changed, 30 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 70ded2b2..5cb103cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2.12 - ?
+ - !scr command for Multi::IRC
+
2.11 - 2010-02-06
- Added Slovak to the language list
- Centered the thumbnails on the screenshots viewer
diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm
index 0b19ed05..f0a6fe6a 100644
--- a/lib/Multi/IRC.pm
+++ b/lib/Multi/IRC.pm
@@ -53,7 +53,7 @@ sub spawn {
_start shutdown throttle_gc irc_001 irc_public irc_ctcp_action irc_msg
command idlequote reply notify_init notify notify_result
cmd_info cmd_list cmd_uptime cmd_vn cmd_vn_results cmd_p cmd_p_results cmd_quote cmd_quote_result
- cmd_say cmd_me cmd_notifications cmd_eval cmd_die cmd_post cmd_api vndbid formatid
+ cmd_scr cmd_scr_result cmd_say cmd_me cmd_notifications cmd_eval cmd_die cmd_post cmd_api vndbid formatid
|],
],
heap => {
@@ -73,6 +73,7 @@ sub spawn {
vn => 0, # 2: only users matching the mask in @masters
p => 0, # |8: has to be addressed to the bot (e.g. 'Multi: eval' instead of '!eval')
quote => 0,
+ scr => 0,
say => 1|8,
me => 1|8,
notifications => 1,
@@ -413,6 +414,31 @@ sub cmd_quote_result { # 1, res, dest
}
+sub cmd_scr {
+ my $q = $_[ARG]||'';
+ $q = $1 if $q =~ /([0-9]+)\.jpg/;
+ return $_[KERNEL]->yield(reply => $_[DEST],
+ q|Sorry, I failed to comprehend which screenshot you'd like me to lookup for you,|
+ .q| please understand that Yorhel was not willing to supply me with mind reading capabilities.|,
+ $_[USER]) if !$q || $q !~ /^[0-9]+$/;
+ return $_[KERNEL]->yield(reply => $_[DEST], 'Stop abusing me, it\'s not like I enjoy spamming this channel!', $_[USER])
+ if throttle $_[HEAP], "query-$_[USER]-$_[DEST][0]", 60, 3;
+ $_[KERNEL]->post(pg => query => q|
+ SELECT 'v'::text AS type, v.id, vr.title
+ FROM vn v
+ JOIN vn_rev vr ON vr.id = v.latest
+ JOIN vn_rev vr2 ON vr2.vid = v.id
+ JOIN vn_screenshots vs ON vs.vid = vr2.id
+ WHERE vs.scr = ? LIMIT 1|, [ $q ], "cmd_scr_result", \@_);
+}
+
+
+sub cmd_scr_result {
+ return $_[KERNEL]->yield(reply => $_[ARG2][DEST], 'Couldn\'t find VN with that screenshot.', $_[ARG2][USER]) if $_[ARG0] < 1;
+ $_[KERNEL]->yield(formatid => $_[ARG0], $_[ARG1], [$_[ARG2][DEST]]);
+}
+
+
sub cmd_say {
my $chan = $_[ARG] =~ s/^(#[a-zA-Z0-9-_.]+) // ? $1 : $_[DEST];
$irc->yield(privmsg => $chan, $_[ARG]);