diff options
author | David Phillips <david@yeah.nah.nz> | 2018-11-15 23:51:43 +1300 |
---|---|---|
committer | David Phillips <david@yeah.nah.nz> | 2018-11-15 23:51:43 +1300 |
commit | 7e58f49fe7499f7ab55436a842f9872be5bc6fd4 (patch) | |
tree | c108efc65a372841c2da2e16679cf9fa8ae2fa45 | |
parent | f598474aeb237e18b90720797bcc274e4675dddb (diff) | |
download | idalius-7e58f49fe7499f7ab55436a842f9872be5bc6fd4.tar.xz |
Add greeter plugin
-rw-r--r-- | Plugin/Greet.pm | 54 | ||||
-rwxr-xr-x | idalius.pl | 22 |
2 files changed, 76 insertions, 0 deletions
diff --git a/Plugin/Greet.pm b/Plugin/Greet.pm new file mode 100644 index 0000000..c281558 --- /dev/null +++ b/Plugin/Greet.pm @@ -0,0 +1,54 @@ +package Plugin::Greet; + +use strict; +use warnings; + +my $root_config; + +sub configure { + my $self = shift; + shift; # cmdref + shift; # run_command + shift; # module config + $root_config = shift; + + return $self; +} + +sub some { + my @choices = @_; + return $choices[rand(@choices)]; +} + +my @own_responses = ( + "It's me! I was the turkey all along!", + "Meeeeeee!", + "Hello, fellow humans", + "Hello", + "Hi", + "Morning all", + "Greetings, fellow earthlings", + "I'm back, baby!", + "I only came back to grab my keys", + "Has anyone seen my keys?", + "Anyone wanna listen to my podcast?" +); + +sub on_join { + my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_; + my $nick = (split /!/, $who)[0]; + if ($nick eq $root_config->{current_nick}) { + return some @own_responses; + } else { + return some( + "hi $nick", + "oh look, $nick is here", + "look who came crawling back", + "look at what the cat dragged in", + "$nick!!!!! guys!!!!!! $nick is here !!!!!!!!", + "weclome $nick", + "Welcome to $where->[0], $nick. Leave your sanity at the door", + "I feel sick"); + } +} +1; @@ -60,6 +60,8 @@ POE::Session->create( irc_ctcp_action irc_public irc_msg + irc_join + irc_part irc_invite irc_nick irc_disconnected @@ -271,6 +273,26 @@ sub irc_public { return handle_common("message", $who, $where, $what, $ided); } +sub irc_join { + my ($who, $channel) = @_[ARG0 .. ARG1]; + my @where = ($channel); + my $nick = ( split /!/, $who )[0]; + + log_info("[$channel] >>> $who joined"); + + return handle_common("join", $who, \@where, ""); +} + +sub irc_part { + my ($who, $channel, $why) = @_[ARG0 .. ARG2]; + my $nick = ( split /!/, $who )[0]; + my @where = ($channel); + + log_info("[$channel] <<< $who left ($why)"); + + return handle_common("part", $who, \@where, $why); +} + sub irc_msg { my ($who, $to, $what, $ided) = @_[ARG0 .. ARG3]; my $nick = (split /!/, $who)[0]; |