summaryrefslogtreecommitdiff
path: root/lib/Multi/IRC.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-08-05 14:09:02 +0200
committerYorhel <git@yorhel.nl>2009-08-05 14:11:55 +0200
commit0d88a7d3b931fa5e7d2318c58ff62d95be7653ae (patch)
tree2e940dd8de005bdcef6012efdbd32976978f4c2c /lib/Multi/IRC.pm
parent4cb5b4f0f3889dd41212e6c9a82db804ad35731c (diff)
Multi::IRC: Spam random quotes in idle channels
'idle' is currently defined as 60+rand(300) minutes, so it'll only occur in *very* idle channels... might be an idea to lower these numbers later on.
Diffstat (limited to 'lib/Multi/IRC.pm')
-rw-r--r--lib/Multi/IRC.pm16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm
index 43007e2f..2bb66dc8 100644
--- a/lib/Multi/IRC.pm
+++ b/lib/Multi/IRC.pm
@@ -48,7 +48,7 @@ sub spawn {
POE::Session->create(
package_states => [
$p => [qw|
- _start shutdown throttle_gc irc_001 irc_public irc_ctcp_action irc_msg command reply
+ _start shutdown throttle_gc irc_001 irc_public irc_ctcp_action irc_msg command idlequote reply
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
|],
@@ -61,6 +61,7 @@ sub spawn {
masters => [ 'yorhel!*@*' ],
@_,
throttle => {},
+ idlequotes => {},
notify => [],
commands => {
info => 0, # argument = authentication level/flags,
@@ -147,12 +148,14 @@ sub _start {
$_[KERNEL]->sig(shutdown => 'shutdown');
$_[KERNEL]->delay(throttle_gc => 1800);
+ $_[KERNEL]->delay(idlequote => 300);
}
sub shutdown {
$irc->yield(shutdown => $_[ARG1]);
$_[KERNEL]->delay('throttle_gc');
+ $_[KERNEL]->delay('idlequote');
$_[KERNEL]->alias_remove('irc');
}
@@ -170,6 +173,7 @@ sub irc_001 {
sub irc_public { # mask, dest, msg
+ $_[HEAP]{idlequotes}{$_[ARG1][0]} = 0;
return if $_[KERNEL]->call($_[SESSION] => command => @_[ARG0..$#_]);
$_[KERNEL]->call($_[SESSION] => vndbid => $_[ARG1], $_[ARG2]);
}
@@ -211,6 +215,16 @@ sub command { # mask, dest, msg
}
+sub idlequote {
+ for (keys %{$_[HEAP]{idlequotes}}) {
+ next if --$_[HEAP]{idlequotes}{$_} > 0;
+ $_[KERNEL]->yield(cmd_quote => '', [$_]) if $_[HEAP]{idlequotes}{$_} == 0;
+ $_[HEAP]{idlequotes}{$_} = int(60+rand(300));
+ }
+ $_[KERNEL]->delay(idlequote => 60);
+}
+
+
# convenience function
sub reply { # target, msg [, mask/user]
my $usr = $_[ARG0][0] =~ /^#/ && parse_user($_[ARG2]);