2 # OnJoin.pl: emit a message when a user enters the channel
3 # Author: Corey Edwards <tensai@zmonkey.org>
10 use vars qw(%channels %param);
11 use vars qw($dbh $who $chan);
14 my ($nick, $user, $host, $chan) = @_;
17 # look for a channel specific message
18 my $message = &sqlSelect('onjoin', 'message', { nick => $nick, channel => $chan } ) || 0;
20 # look for a default message
22 $message = &sqlSelect('onjoin', 'message', { nick => $nick, channel => '_default' } ) || 0;
25 # print the message, if there was one
27 &status("OnJoin: $nick arrived, printing message");
28 &msg($chan, $message);
34 # set and get messages
37 m/(\S*)( (\S*)( (.*)|)|)/;
43 my $strict = &getChanConf('onjoinStrict');
44 my $ops = &getChanConf('onjoinOpsOnly');
46 # see if they specified a channel
47 if ($ch !~ m/^\#/ && $ch ne '_default'){
55 if ($nick =~ m/^-(.*)/){
58 if (!$channels{$chan}{o}{$who}){
59 &performReply("sorry, you're not an operator");
63 # regardless of strict mode, ops can always change
64 if (!$channels{$chan}{o}{$who} and $nick ne $who){
65 &performReply("I can't alter a message for another user (strict mode)");
69 &sqlDelete('onjoin', { nick => $nick, channel => $ch });
75 # if msg not set, show what the message would be
77 $nick = $who if (!$nick);
78 $msg = &sqlSelect('onjoin', 'message', { nick => $nick, channel => $ch } ) || '';
85 # only allow changes by ops
87 if (!$channels{$chan}{o}{$who}){
88 &performReply("sorry, you're not an operator");
92 # only allow people to change their own message (superceded by OpsOnly)
94 # regardless of strict mode, ops can always change
95 if (!$channels{$chan}{o}{$who} and $nick ne $who){
96 &performReply("I can't alter a message for another user (strict mode)");
101 # remove old one (if exists) and add new message
102 &sqlDelete('onjoin', { nick => $nick, channel => $ch });
103 &sqlInsert('onjoin', { nick => $nick, channel => $ch, message => $msg });