2 # OnJoin.pl: emit a message when a user enters the channel
10 use vars qw(%channels %param);
11 use vars qw($dbh $who $chan);
14 my ($nick, $user, $host, $chan) = @_;
16 my $message = &sqlSelect('onjoin', 'message', { nick => $n, channel => $chan } ) || 0;
18 # print the message, if there was one
20 &status("OnJoin: $nick arrived");
21 &msg($chan, $message);
27 # set and get messages
30 $msg =~ m/(.*?)( (.*))/;
34 # if msg not set, show what the message would be
36 $nick = $who if (!$nick);
37 $msg = &sqlSelect('onjoin', 'message', { nick => $nick, channel => $chan } ) || '';
45 my $strict = &getChanConf('onjoinStrict');
46 my $ops = &getChanConf('onjoinOpsOnly');
48 # only allow changes by ops
50 if (!$channels{$chan}{o}{$who}){
51 &performReply("sorry, you're not an operator");
55 # only allow people to change their own message (superceded by OpsOnly)
57 # regardless of strict mode, ops can always change
58 if (!$channels{$chan}{o}{$who} and $nick ne $who){
59 &performReply("I can't alter a message for another user (strict mode)");
64 &sqlDelete('onjoin', { nick => $nick, channel => $chan});
65 &sqlInsert('onjoin', { nick => $nick, channel => $chan, message => $msg});