1 #**************************************************************************
2 # Copyright (C) 2009 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
22 use vars qw($VERSION %IRSSI);
30 contact => "harv\@ruin.nu",
31 name => "NewDawn testbot script",
32 description => "Testbot used for implementing commands for nd bots",
33 license => "GPL-2 or (at your option) any later version",
47 use again 'ND::Include';
48 use again 'NDIRC::Dispatcher';
49 use again 'NDIRC::Context';
50 use again 'NDIRC::Command';
51 use again 'NDIRC::Misc';
54 my $TICK = $DBH->selectrow_array('SELECT tick()');
56 my $disp = new NDIRC::Dispatcher;
58 $disp->load('Basic','PA','Channel','Scans','Quotes','Members','Usermgm','Intel');
60 $ND::scanchan = '#testarmer';
61 $disp->add_channel('#testarlite', ['pub','help','channel','def']);
62 $disp->add_channel($ND::scanchan, ['pub','help','channel','scan','member']);
63 $disp->add_channel('pm', ['pub','help','pm']);
66 my ($server, $msg, $nick, $address, $channel) = @_;
69 if ($msg =~ /^(\S+): (.+)$/ && $disp->has_command('anon',$channel)){
72 my $channel = $server->channel_find($channel);
73 my $nick = $channel->nick_find($1);
74 unless ($nick || /(Constructing|Researching)/){
75 print ".anon $_ $text";
76 $msg = ".anon $_ $text";
80 if (parseCommand($msg,$server,$nick,$address,$channel,$disp,DB())){
81 #Command parsed and run successfully
88 my ($server, $msg, $nick, $address) = @_;
91 if (parseCommand($msg,$server,$nick,$address,'pm',$disp,DB())){
92 #Command parsed and run successfully
99 print "SiG" if $ND::refresh;
103 Irssi::timeout_add(60*1000, 'refresh', undef);
104 Irssi::timeout_add(1000, sub{refresh if $ND::refresh}, undef);
105 Irssi::signal_add('message public','event_pubmsg');
106 Irssi::signal_add('message private','event_privmsg');