-#v1: blootbot -- blootbot -- written Fri Aug 12 22:01:53 2005
+#v1: blootbot -- blootbot -- written Sun Jan 1 22:59:37 2006
#botpark
+RootWarn
- _time_added 1108710504
- autojoin
+ +autojoin
#debian-bots
+News
+HTTPDtype
+Kernel
+Math
+ +OnJoin
+Plug
+Quote
+Rss
--- /dev/null
+CREATE TABLE onjoin (
+ nick VARCHAR(20) NOT NULL,
+ channel VARCHAR(16) NOT NULL,
+ message VARCHAR(255) NOT NULL
+);
&addCmdHook('quote', ('CODEREF' => 'Quote::Quote', 'Forker' => 1, 'Identifier' => 'Quote', 'Help' => 'quote', 'Cmdstats' => 'Quote') );
&addCmdHook('reverse', ('CODEREF' => 'reverse::reverse', 'Identifier' => 'reverse', 'Cmdstats' => 'reverse', 'Forker' => 1, 'Module' => 'reverse') );
&addCmdHook('RootWarn', ('CODEREF' => 'CmdrootWarn', 'Identifier' => 'RootWarn', 'Module' => 'RootWarn') );
+&addCmdHook('OnJoin', ('CODEREF' => 'Cmdonjoin', 'Identifier' => 'OnJoin', 'Module' => 'OnJoin') );
&addCmdHook('Rss', ('CODEREF' => 'Rss::Rss', 'Identifier' => 'Rss', 'Cmdstats' => 'Rss', 'Forker' => 1, 'Help' => 'rss') );
&addCmdHook('sched(stats|info)', ('CODEREF' => 'scheduleList', ) );
&addCmdHook('scramble', ('CODEREF' => 'scramble::scramble', 'Identifier' => 'scramble', 'Cmdstats' => 'scramble', 'Forker' => 1, 'Module' => 'scramble') );
&loadMyModule('RootWarn');
delete $cache{confvars}{$_};
}
+
+ if (/^onjoin$/i and $i) {
+ &loadMyModule('OnJoin');
+ delete $cache{confvars}{$_};
+ }
}
&DEBUG("end of rehashConfVars");
$user =~ /^~?r(oo|ew|00)t$/i
);
+ ### emit a message based on who just joined
+ &onjoin($who,$user,$host,$chan) if (&IsChanConf('OnJoin'));
+
### NEWS:
if (&IsChanConf('News') && &IsChanConf('newsKeepRead')) {
if (!&loadMyModule('News')) { # just in case.
--- /dev/null
+#
+# OnJoin.pl: emit a message when a user enters the channel
+# Author: tensai
+# Version: v0.1
+# Created: 20051222
+# Updated: 20051230
+
+use strict;
+
+use vars qw(%channels %param);
+use vars qw($dbh $who $chan);
+
+sub onjoin {
+ my ($nick, $user, $host, $chan) = @_;
+ my $n = lc $nick;
+ my $message = &sqlSelect('onjoin', 'message', { nick => $n, channel => $chan } ) || 0;
+
+ # print the message, if there was one
+ if ($message){
+ &status("OnJoin: $nick arrived");
+ &msg($chan, $message);
+ }
+
+ return;
+}
+
+# set and get messages
+sub Cmdonjoin {
+ my $msg = shift;
+ $msg =~ m/(.*?)( (.*))/;
+ my $nick = $1;
+ $msg = $3;
+
+ # if msg not set, show what the message would be
+ if (!$msg){
+ $nick = $who if (!$nick);
+ $msg = &sqlSelect('onjoin', 'message', { nick => $nick, channel => $chan } ) || '';
+ if ($msg){
+ &performReply($msg);
+ }
+ return;
+ }
+
+ # get params
+ my $strict = &getChanConf('onjoinStrict');
+ my $ops = &getChanConf('onjoinOpsOnly');
+
+ # only allow changes by ops
+ if ($ops){
+ if (!$channels{$chan}{o}{$who}){
+ &performReply("sorry, you're not an operator");
+ return;
+ }
+ }
+ # only allow people to change their own message (superceded by OpsOnly)
+ elsif ($strict){
+ # regardless of strict mode, ops can always change
+ if (!$channels{$chan}{o}{$who} and $nick ne $who){
+ &performReply("I can't alter a message for another user (strict mode)");
+ return;
+ }
+ }
+
+ &sqlDelete('onjoin', { nick => $nick, channel => $chan});
+ &sqlInsert('onjoin', { nick => $nick, channel => $chan, message => $msg});
+ &performReply("ok");
+ return;
+}
+
+1;
# create database not needed for SQLite
}
- foreach ( qw(botmail connections factoids rootwarn seen stats) ) {
+ foreach ( qw(botmail connections factoids rootwarn seen stats onjoin) ) {
if (exists $db{$_}) {
$cache{has_table}{$_} = 1;
next;
my @myModulesLoadNow;
my @myModulesReloadNot;
BEGIN {
- @myModulesLoadNow = ('Topic', 'Uptime', 'News', 'RootWarn', 'DumpVars2', 'botmail');
+ @myModulesLoadNow = ('Topic', 'Uptime', 'News', 'RootWarn', 'DumpVars2', 'botmail', 'OnJoin');
@myModulesReloadNot = ('IRC/Irc.pl','IRC/Schedulers.pl');
}