summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-08-05 12:33:29 +0200
committerYorhel <git@yorhel.nl>2009-08-05 12:33:50 +0200
commit5e81427c6e2c34b912feccd803c73de847a9e93c (patch)
tree90aa7f125c882df1927e74d8a82278fa115d6198 /lib
parenta8dc63a5282c071e70c91e8b7adcd76e5545d873 (diff)
Multi::IRC: Added !quote command to reply with a random quote from the DB
Diffstat (limited to 'lib')
-rw-r--r--lib/Multi/IRC.pm15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm
index 88de3dad..92f887ea 100644
--- a/lib/Multi/IRC.pm
+++ b/lib/Multi/IRC.pm
@@ -49,7 +49,7 @@ sub spawn {
package_states => [
$p => [qw|
_start shutdown irc_001 irc_public irc_ctcp_action irc_msg command reply
- cmd_info cmd_list cmd_uptime cmd_vn cmd_vn_results cmd_say cmd_me
+ cmd_info cmd_list cmd_uptime cmd_vn cmd_vn_results cmd_quote cmd_quote_result cmd_say cmd_me
cmd_eval cmd_die cmd_post vndbid formatid
|],
],
@@ -68,7 +68,8 @@ sub spawn {
list => 0, # 0: everyone,
uptime => 0, # 1: only OPs in the first channel listed in @channels
vn => 0, # 2: only users matching the mask in @masters
- say => 1|8, # |8: has to be addressed to the bot (e.g. 'Multi: eval' instead of '!eval')
+ quote => 0, # |8: has to be addressed to the bot (e.g. 'Multi: eval' instead of '!eval')
+ say => 1|8,
me => 1|8,
eval => 2|8,
die => 2|8,
@@ -258,6 +259,16 @@ sub cmd_vn_results { # num, res, \@_
}
+sub cmd_quote {
+ $_[KERNEL]->post(pg => query => q|SELECT quote FROM quotes ORDER BY random() LIMIT 1|, undef, 'cmd_quote_result', $_[DEST]);
+}
+
+
+sub cmd_quote_result { # 1, res, dest
+ $_[KERNEL]->yield(reply => $_[ARG2] => $_[ARG1][0]{quote}) if $_[ARG0] > 0;
+}
+
+
sub cmd_say {
my $chan = $_[ARG] =~ s/^(#[a-zA-Z0-9-_.]+) // ? $1 : $_[DEST];
$irc->yield(privmsg => $chan, $_[ARG]);