#!/usr/bin/perl # # DreamBot - An Experimental IRC Bot written in Perl. # Copyright (C) 1999-2002 Osman "spectre" Keskin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $ver = "DreamBot 0.0.7"; $version = "$ver - Experimental Perl Bot"; $config = "config"; $curserver = 0; $curnick = 0; $seenflag = false; $bitchflag = false; $params = ""; for ($i = 0; $i < $#ARGV + 1; $i++) { if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "--help") { printf("$version\n"); printf("Usage: $0 \n\n"); printf(" -c --config use the file for configuration\n"); printf(" -d --datadir sets the datadir, default is set in config file\n"); printf(" -h --help help\n"); exit(0); } elsif ($ARGV[$i] eq "-c" || $ARGV[$i] eq "--config") { $i++; if ($ARGV[$i] ne "") { $config = $ARGV[$i]; $params .= " -c $config"; } else { printf("Usage:\n --config \n"); exit(0); } } elsif ($ARGV[$i] eq "-d" || $ARGV[$i] eq "--datadir") { $i++; if ($ARGV[$i] ne "") { $newdatadir = $ARGV[$i]; $params .= " -d $datadir"; } else { printf("Usage:\n --datadir \n"); exit(0); } } } if (open(FILE, "$ENV{HOME}/.dreambot.pid")) { # $pid = ; close(FILE); # if ($$ eq $pid) { exit(0); } exit(0); } open(FILE, ">$ENV{HOME}/.dreambot.pid"); printf FILE "$$\n"; close(FILE); undef(@on_join_handler); undef(@on_part_handler); undef(@on_quit_handler); undef(@on_msg_handler); do "$config"; if (defined($newdatadir)) { $datadir = $newdatadir; } $datadir =~ s/~/$ENV{HOME}/; $logdir =~ s/~/$ENV{HOME}/; use Socket; #use Thread; $help{raw} = "Syntax: .raw \nSends directly to the server."; $help{order} = "Syntax: .order \nSends directly to the server."; $help{quote} = "Syntax: .quote \nSends directly to the server."; $help{ctcp} = "Syntax: .ctcp \nJust like doing /ctcp \nYou can make the bot ctcp version someone by doing .ctcp VERSION"; $help{cycle} = "Syntax: .cycle \nRejoins the ."; $help{addchan} = "Syntax: .addchan \nAdds/updates a channel with . Availabled flags are: modes, log, modelock, topiclock, bitch, opprot, needinvite, freshmeat, slashdot"; $help{setchan} = "Syntax: .setchan \nAdds/updates a channel with . Availabled flags are: modes, log, modelock, topiclock, bitch, opprot, needinvite, freshmeat, slashdot"; $help{remchan} = "Syntax: .remchan \nRemoves from channel list."; $help{chaninfo} = "Syntax: .chaninfo []\nDisplays channel settings"; $help{adduser} = "Syntax: .adduser \nAdds/updates an user record.\nHostmasks and channels are separated by commas. Flags aren't seperated.\nPut '*' to channels to give access on every channel\nExample: .adduser spectre ?spectre@*.mylovelyisp.com mo *"; $help{setuser} = "Syntax: .setuser \nAdds/updates an user record.\nHostmasks and channels are separated by commas. Flags aren't seperated.\nPut '*' to channels to give access on every channel\nExample: .setuser spectre ?spectre@*.mylovelyisp.com mo *"; $help{remuser} = "Syntax: .remuser \nRemoves an user record"; $help{showuser} = "Syntax: .showuser \nShows the user record"; $help{serverlist} = "Syntax: .serverlist\nPrints server list"; $help{userlist} = "Syntax: .userlist\nPrints user list"; $help{chanlist} = "Syntax: .chanlist\nPrints chan list"; $help{save} = "Syntax: .save\nSaves everything (userbase, channels, facts, notes, seen db, top talkers etc)"; $help{topiclock} = "Syntax: .topiclock []\nEnables/disables topiclock. Specifiy if you /msg the bot"; $help{modelock} = "Syntax: .modelock []\nEnables/disables modelock. Specifiy if you /msg the bot"; $help{bitchmode} = "Syntax: .bitchmode []\nEnables/disables bitch mode. Specifiy if you /msg the bot"; $help{opprot} = "Syntax: .opprot []\nEnables/disables op protection. Specifiy if you /msg the bot"; $help{log} = "Syntax: .log []\nEnables/disables channel log. Specifiy if you /msg the bot"; $help{nick} = "Syntax: .nick \nChanges bot's nick to "; $help{join} = "Syntax: .join \nBot simply joins . It doesn't add to the channel list."; $help{part} = "Syntax: .part \nBot simply leaves . It doesn't remove from the channel list."; $help{say} = "Syntax: .say \nMakes bot say on ."; $help{topic} = "Syntax: .topic \nMakes bot set on ."; $help{mode} = "Syntax: .mode \nMakes bot set on ."; $help{op} = "Syntax: .op \nBot ops "; $help{dop} = "Syntax: .dop \nBot deops "; $help{deop} = "Syntax: .deop \nBot deops "; $help{kick} = "Syntax: .kick \nMakes bot kick outta with ."; $help{ban} = "Syntax: .ban \nMakes bot ban on "; $help{unban} = "Syntax: .unban \nMakes bot unban on "; $help{flag} = "Syntax: .flag [+/-]\nSets, adds, removes user flags"; $help{flags} = "Syntax: .flags [+/-]\nSets, adds, removes user flags"; $help{addhost} = "Syntax: .addhost \nAdds a new to "; $help{remhost} = "Syntax: .remhost \nRemoves the from "; $help{addchanuser} = "Syntax: .addchanuser \nGives access on . You can't add '*' with this command."; $help{die} = "Syntax: .die []\nBot dies painfully"; $help{restart} = "Syntax: .restart []\nRestarts the bot"; $help{jump} = "Syntax: .jump [:]\nBot jumps to the . This command doesn't add to the server list."; $help{help} = "Syntax: .help []\nGuess what"; @dunno = ('I\'ve no idea', 'I dunno', 'never heard about it', 'no idea', 'umm.. dunno', 'lemme think about it'); do 'subs.pl'; do 'parser.pl'; $SIG{KILL} = 'terminate'; $SIG{TERM} = 'terminate'; $SIG{INT} = 'terminate'; $SIG{ALRM} = 'saveall'; $SIG{CHLD} = sub { wait() }; $| = 1; if ($log eq true) { open(LOGFILE, ">>$logfile"); printf LOGFILE "\n[start]\n"; } loadchannels(); loadusers(); loadnotes(); loadfacts(); loadseen(); loadtopiclocks(); loadtalkers(); loadpasswords(); serverconnect(); alarm 3600; while (1) { $ln = getline($sock); if ($ln ne "") { parser($ln); } }