Page MenuHomeDevCentral

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/README b/README
index f9adc5b..50d3241 100644
--- a/README
+++ b/README
@@ -1,60 +1,55 @@
Darkbot, Talking Robot - Copyright (c) 1996 Darkbot Project
- To build your Darkbot on Unixes (or cygwin),
run the ./build.sh script.
- For full documentation and step by step configuration help,
-please check Darkbot's help page at http://www.freezedown.org/help
+please check Darkbot's help page at http://darkbot.sourceforge.net
- Read docs/WHATSNEW for added/latest features and changes.
- Read docs/README_UTILS for info on shell utilities and all files in
scripts dir.
- If you are running a Darkbot with version release prior to 7.0
use convertdb to convert your userlist.db to an encrypted password
format. Users will need to set their passwords on IRC which initial
value would be 0(zero). convertdb script and all integrated Darkbot
utility scripts are on scripts directory.
- If your bot is stupid, and you want it to know some general
stuff, download pre-made databases from the Darkbot site. You should be
aware of database mechanics before installing and running any database.
Darkbot should compile and run on a lot of operating systems (OS).
Please note that the darkbot team is small, most of the time there's
only one developer actively working on it, in their spare time. So we
can't support every version of every OS under the sun, we just don't
have the time for them all. Some OS's are free to install, some cost
money, some cost a lot of money. So, we have to draw the line
somewhere. The general principle is that we support the oldest stable
release that is still supported by the OS maker from BSD (FreeBSD,
OpenBSD, and Mac OS X), Linux (Debian and Ubuntu), and Windows. The
assumption is that later versions should be backwards compatible enough.
Also, it should be easy to get these running on a VM, preferably qemu.
More Linux varieties might be added, especially RPM based ones.
This program is provided free for non-commercial use only. Any
commercial use of this source code or binaries compiled thereof
requires the prior written consent of the project administrator.
Distribution of modified source code or binaries compiled from
modified source code for any platform is expressly forbidden!
All code patches to be applied to the program are donations to
the project and must remain under this terms and conditions.
No code with copyright statements other than the ones ruled by this
project is accepted unless agreed by all parties in writing.
All Darkbot program and information is provided as is without
warranty of any kind. In any event shall Darkbot project or any
of it's collaborators be liable for any damages whatsoever.
If you do not agree with the above user disclaimer, please do not
use the program and delete all Darkbot files.
-Contact juice@freezedown.org with any questions regarding the use
-of this program.
Darkbot is a creation of Jason Hamilton [ Jason@superlink.net ]
and has been coded by several contributors who donates their
code patches to the project. Please read file contributors in
docs directory with a list of who makes this program possible.
-
-Project Administrator
-juice (juice@freezedown.org)
diff --git a/dat/servers.ini b/dat/servers.ini
index e841a3a..c7c963c 100644
--- a/dat/servers.ini
+++ b/dat/servers.ini
@@ -1,3 +1,3 @@
-# Freezedown "Darkbot" Server
-irc.freezedown.org 6667 nopass
-
+# Freenode.net "Darkbot" Official Network Servers
+chat.freenode.net 6667 nopass
+irc.freenode.net 6667 nopass
diff --git a/dat/setup.ini b/dat/setup.ini
index a2141e7..9bc1cc4 100644
--- a/dat/setup.ini
+++ b/dat/setup.ini
@@ -1,62 +1,62 @@
ANTI_IDLE=0
BITCH_DEOP=0
BITCH_DEOP_TEXT=grr, someone op me!
BITCH_KICK_TEXT=grrr, kick me again and I'm going to...
BOT_CMD_CHAR=!
BOT_NICK=Darkbot
-BOT_NAME=http://www.freezedown.org
-BOT_USER_ID=database
+BOT_NAME=http://darkbot.sourceforge.net
+BOT_USER_ID=darkbot
BOT_USER_MODE=+i-ds
BOT_VHOST=0
CONNECT_TIME=10
DEFAULT_CHANNEL=#darkbot
DISPLAY_SYNC=0
DO_WHOIS=0
DUNNO_TEXT=*shrug*
DUNNO_RANDOM_TEXT=1
DUPS_REMOVE=0
DUPS_SAVE=1
ENTRY_EXISTS_TEXT=Sorry, there is an existing entry under keyword
ENTRY_NOT_EXIST_TEXT=I was unable to find entry:
FIND_NO_TEXT=Sorry, I don't have any entry for
FIND_WHAT_TEXT=What am I trying to find
FLOOD_NOTICE_KICK=1
FLOOD_NOTICE_BAN=0
FLOOD_NOTICE_BAN_HOST=0
FLOOD_KICK=1
FLOOD_TEXT=Don't flood!
GREET_GUESTS_TEXT=0
GREET_NEW_TEXT=0
GREET_USER_TEXT=1
IGNORE_TIME=5
IGNORE_USER_TIME=60
KICK_TEXT=Requested!
KICK_ON_BAN=0
LOG_CHANGES=1
LOG_PRIVATE=1
OP_ON_LOGIN=0
OUTPUT1_COUNT=4
OUTPUT1_TIME=1
OUTPUT2_COUNT=6
OUTPUT2_TIME=2
OUTPUT_PURGE_COUNT=7
OUTPUT3_TIME=3
PERFORM_TIME=1
QUESTIONS_GENERAL=1
QUESTIONS_PRIVATE=0
RANDOM_BACKUP=0
RANDOM_IDLE_TIME=1800
RANDOM_TIME=3600
SEEN_MODE=1
SEEN_TIME=604800
SEEN_TEXT=in the last 7 days.
SETINFO_TEXT=My !setinfo variables are: ^ nick, % Number of joins, & Channel, $ user@host. Example: !setinfo ^ has joined & % times!! (also, if you make the first char of your SETINFO a "+" the setinfo will be shown as an ACTION)
SLEEP_TIME=300
SLEEP_TEXT=ACTION falls asleep... ZzzZZzzZZzz
SLEEP_WAKE_TEXT=ACTION wakes up from a snooze..
SORT_DB=0
TOPIC_TIME=1800
VARIABLES_TEXT=Data variables are: N~ (Nick), C~ (Chan), T~ (Time/date) B~ (Botnick), Q~ (Question asked), R~ (random nick), !~ (command char), S~ (current Server), P~ (current port) V~ (botVer), W~ (db WWW site), H~ (u@h), t~ (unixtime), BAN (sets a ban), TEMPBAN (bans for 60 sec)
VOICE_ON_JOIN=0
WHUT_TEXT=hmmm?
WHUT_RANDOM_TEXT=1
diff --git a/docs/AUTHORS b/docs/AUTHORS
index 6749d2e..0ba36dc 100644
--- a/docs/AUTHORS
+++ b/docs/AUTHORS
@@ -1,122 +1,98 @@
- **** Darkbot Contributors ****
-
-The following is a list of people who have made contributions to Darkbot.
-We intend this list to be as complete as possible, but if you have any
-corrections, modifications, or additions, please let us know. We don't
-want to leave any contributors unnoticed.
-
-Author/Creator: Jason Hamilton (play) <jason@superlink.net>
-Project Administrator: juice (juice) <juice@freezedown.org>
-
-A large portion of Darkbot's code, although primarily and mainly done
-by Jason Hamilton, is also made possible by the following contributors.
-
-Thanks to everyone for their contributions to this project.
-
-**** Coders ****
-
-Ron Robbins Jr. (ron) <ron@freezedown.org>
- * A plethora of changes, modifications, and bug fixes since version 6f6.
-David Seikel (onefang) <onefang@gmail.com>
- * A plethora of changes, modifications, and bug fixes since version 8rc2.
-Paul (reet2) <paul@darkbot.info>
- * Several major changes on 6f6 for release 7. Added the quiz stuff,
- and original google functionality.
-Neil Darlow
- * Code optimization patches on info and check_permban on prep 7 - 3/22/2002
-Bart Jansens
- * Typo correction on Dutch language / prep 7 April 10, 2000
-Dan (ripper_) @ undernet
- * Several major changes - 5f21,22,23,26
-Kosh @ superchat
- * Implementation of WIN32 port
-s0meguy @ undernet
- * found a missing variable April v. 5f22 -- 16, 23, 2000
-Oleg <green@crimea.edu>
- * "repeated server stoned" and NEED_LIB5 corrections - 5f18 5f15
-Fouton <c592030@everest.cclabs.missouri.edu>
- * #define SGI -f18
-nak @ superchat
- * VHOST support - 5f11
-Gator @ superchat
- * 'fclose' issue - 5f3
-[K]aka (at?)
- * A buffer overflow issue - 5-Beta7
-BLightnin @ undernet
- * Datasearch fix; save topic duplicates suggestion of log PRIVMSG - 5-Beta7 4-Alpha2
-rewpaul rew @ undernet
- * Fixed 'pipe' on topics; Q~ variable fix suggestion on mask function; Adduser fix;
- wildcards on topics RANDOM_STUFF OFF on 'Sleep' ON - 5-Beta6 - 5-Beta3 4-Beta2 4-Beta1
-gavers @ undernet
- * Found 'pipe' on topics issue' - 5-Beta6 5-Beta1
-Nenemis (at?)
- * Suggestion on notice help join greeting info - 5-Beta3
-wx @ undernet
- * CTCP replies fix; suggest UP command - 5-Beta1 5-Alpha4
-Zaf @ superchat
- * Suggestion of RANDOM_STUFF Idle - 4-Beta1
-mark @ undernet
- * License usage agreement update - 4-Beta1
-bow @ undernet
- * AddServer fix - 4-Alpha2
-
-and several other anonymous contributors
+'My fellow Homo Sapiens, ask not what your Darkbot can do for you, ask what you can do for your Darkbot.'
-**** Translators ****
-ENGLISH - play <jason@superlink.net>
-FRENCH - Inajira <inajira@videotron.ca>
- - EfX <michel.efx@globetrotter.net>
- - eCHaLoTTe <echalotte@cablevision.qc.ca>
- - Raider <raider@superchat.ws>
-SPANISH - speed1 <speed@edure des.edu.do>
-DUTCH - Asmodai <asmodai@wxs.nl>
- - Dan <dan@ntlbusiness.com>
-LATIN - Otaku <otaku@unixgeek.ml.org>
-GREEK - Chris_CY <chriscy@cylink.net>
- - Raider <raider@superchat.ws>
-EBONICS - rapsux <bitter@ici.net>
-PIG LATIN - Cloud <burtner@usa.net>
-RUSSIAN - KOI8 encoding
-RUSSIAN - CP1251 encoding
- - Oleg Drokin <green@ccssu.crimea.ua>
-PORTUGUESE - Pincel <Pincel@darkbot.info>
-GERMAN - C.Hoegl@gmx.net & marc@reymann.net
- - Dan <dan@ntlbusiness.com>
-ITALIAN - daniele nicolucci <jollino@icemail.it>
-CHINISE - James <jamespower@263.net>
-SWEDISH - Ybznek <sunmo@seaside.se>
-NORWEGIAN - [SoHo] <soho@int19h.com>
-ROMANIAN - Radu <radu.negoescu@sante.univ-nantes.fr>
-ARABIC - MrSiMo <mrsimo7@yahoo.fr>
-
-Other Darkbot related projects
-Darkbot Commander - Alex99 <Alex99@darkbot.info>
+Darkbot is a volunteer runned project being managed, maintaigned, developed and supported by an altruistic group and by the users themselves on wich all contributions are made on the willingness of their contributors who manages their time and contributions the way they find more suitable to their own duties.
+
+
+How to contribute? You could make Darkbot better by bellonging to:
+
+Database Team: Build database entries.
+Support Team: Being a Helper in Support Chat Room or Web Site, Making Tutorials, HowTOs, Tips&Tricks.
+Tester Team: Testing current or Beta versions of the code in your preferred Operating System.
+Translators Team: Translating the main code output text.
+Developing Team: Code; Developing features, correcting malfunctions. How? Check Features Requests, Unsolved Buggs, Ideas.
+Or ponctually repport any malfunction, suggest a new feature, present an idea, make a review, correct any misspeled word, donate a server for running a specialized Darkbot.
+
+Here are the ones who in one way or other, make Darkbot possible, by contributing with their time, skills or by donating services.
+
+**** Darkbot Contributors ****
+
+Author/Creator
+Jason Hamilton (play) <jason@superlink.net>:
+
+Project Administrator
+Luiz Castelo-Branco <LuizCB@users.sourceforge.net>: Web Building, Database Building, Documentation, User Helping, Bash Utilities Script Coding on early releases, Portuguese Translation.
+Lead Developer
+David Seikel (onefang) <onefang@users.sourceforge.net>: A plethora of changes, modifications, and bug fixes since version 8rc2. Cleaning, fixing, featuring/creating Darkbot's 2014 revamping - too many to mention (check GIT commits or/and docs).
+
+Developers with major contributions,
+- Ron Robbins Jr. (ron) <mircsux@users.sourceforge.net>: Developer; A plethora of changes, modifications, and bug fixes since version 6f6.
+- Paul (reet2) <paul@??>: Several major changes on 6f6 for release 7. Added the quiz stuff, and original googlefu nctionality.
+The following are people who acknowledgedly colaborated with Darkbot Project by coding features, submiting code patches, translating, guidind and helping users trough their difficulties, providing web presence for Darkbot Project.
+(by alphanumeric name/nick order)(email addresses are being checked to be updated)
+
+**** Code Patches ****
+
+- [K]aka: [Code] A buffer overflow issue - 5-Beta7
+- bow @ undernet: AddServer fix - 4-Alpha2
+- Bart Jansens: Typo correction on Dutch language / prep 7 April 10, 2000
+- BLightnin @ undernet: Datasearch fix; save topic duplicates suggestion of log PRIVMSG - 5-Beta7 4-Alpha2
+- Dan (ripper_) @ undernet: Several major changes - 5f21,22,23,26
+- Fouton <c592030@everest.cclabs.missouri.edu>: #define SGI -f18
+- gavers @ undernet: Found 'pipe' on topics issue' - 5-Beta6 5-Beta1
+- Gator @ superchat: 'fclose' issue - 5f3
+- Kosh @ superchat: Implementation of WIN32 port
+- nak @ superchat: VHOST support - 5f11
+- Neil Darlow: Code optimization patches on info and check_permban on prep 7 - 3/22/2002
+- Oleg <green@crimea.edu>: " repeated server stoned" and NEED_LIB5 corrections - 5f18 5f15
+- rewpaul rew @ undernet: Fixed 'pipe' on topics; Q~ variable fix suggestion on mask function; Adduser fix;
+- s0meguy @ undernet: found a missing variable April v. 5f22 -- 16, 23, 2000
+wildcards on topics RANDOM_STUFF OFF on 'Sleep' ON - 5-Beta6 - 5-Beta3 4-Beta2 4-Beta1
+- wx @ undernet: CTCP replies fix; suggest UP command - 5-Beta1 5-Alpha4
+**** Translators ****
+- [SoHo] <soho@int19h.com> [NORWEGIAN]
+- Asmodai <asmodai@wxs.nl> [DUTCH]
+- C.Hoegl@gmx.net & marc@reymann.net [GERMAN]
+- Chris_CY <chriscy@cylink.net> [GREEK]
+- Cloud <burtner@usa.net> [PIG LATIN][RUSSIAN - CP1251][RUSSIAN - KOI8 ]
+- daniele nicolucci <jollino@icemail.it> [ITALIAN]
+- Dan <dan@ntlbusiness.com> [DUTCH] [GERMAN]
+- eCHaLoTTe <echalotte@cablevision.qc.ca> [FRENCH]
+- EfX <michel.efx@globetrotter.net> [FRENCH]
+- Inajira <inajira@videotron.ca> [FRENCH]
+- James <jamespower@263.net> [CHINISE]
+- Jason Hamiltton <jason@superlink.net> [ENGLISH]
+- LuizCB <LuizCBl@users.sourceforge.net> [PORTUGUESE]
+- MrSiMo <mrsimo7@yahoo.fr> [ARABIC]
+- Oleg Drokin <green@ccssu.crimea.ua> [RUSSIAN - CP1251]
+- Otaku <otaku@unixgeek.ml.org> [LATIN]
+- rapsux <bitter@ici.net> [EBONICS]
+- Radu <radu.negoescu@sante.univ-nantes.fr> [ROMANIAN]
+- Raider <raider@superchat.ws> [GREEK]
+- speed1 <speed@edure des.edu.do> [SPANISH]
+- Ybznek <sunmo@seaside.se> [SWEDISH]
**** Helpers ****
-These are people who acknowledgedly colaborate with Darkbot Project
- guidind and helping users trough their difficulties
-... by alpha order...
-Alex99 Alex99@darkbot.info / @ undernet #darkbot
-Andre (Syntax6) Syntax6@darkbot.info / @ undernet #darkbot
-baphomet @ undernet #darkbot
-derv0 @ undernet #darkbot
-BLightnin @ undernet #darkbot
-juice @ undernet #darkbot
-Shaky @ undernet #darkbot
-TuEuR @ undernet #darkbot
-{SID_V} @ undernet #darkbot
-
-**** Special Donnations ****
-Andre (Syntax6) Syntax6@darkbot.info
- * has hosted Darkbot Web pages on his servers.
- Has also donated DNS hosting for Darkbot domains.
-
-SourceForge, for hosting one of our mirrors, and giving us nifty
-stats and ratings about the project, that we can gawk at and admire.
-
-LaZZ from www.chatcircuit.net for providing another one of our mirrors.
-
-**** " ****
-
-(PLEASE help keep this list up-to-date by e-mailing juice@freezedown.org
- with any additions.)
+- {SID_V}
+- Alex99 Alex99@??
+- Andre (Syntax6)
+- baphomet
+- BLightnin
+- derv0
+- juice
+- Shaky
+- TuEuR
+
+**** Web Presence and other contributions ****
+- Andre (Syntax6) has hosted Darkbot Web pages and donated DNS hosting on his servers.
+- Jared Smith (juice) <juicebar@users.sourceforge.net>: Managed Darkbot's Web presence while Luiz Castelo-Branco was absent.
+- LaZZ for providing a web site mirror.
+- mark @ undernet: License usage agreement update - 4-Beta1
+- Nenemis: Suggestion on notice help join greeting info - 5-Beta3
+- Zaf @ superchat: Suggestion of RANDOM_STUFF Idle - 4-Beta1
+
+SourceForge(.net), in being our official project and web site hosting service.
+
+... and several other anonymous contributors.
+If we are missing anyone or you find any incorrection please inform the Project Administrator.
+
+To all, Darkbot Project thanks you very much.
diff --git a/docs/INSTALL b/docs/INSTALL
index 88abbb3..cfb4dbe 100644
--- a/docs/INSTALL
+++ b/docs/INSTALL
@@ -1,526 +1,526 @@
##################################################################################
Darkbot, Talking Robot - Copyright (c) 1996 Darkbot Project
Welcome to the Darkbot install file. This will be a step by step guide to
installing your Darkbot, so read it all, before you do anything.
If you have not read this file and come into the help channel on the Darkbot
Network, we will know, and it might mean you will be helped last.
With that out of the way, if you have done every thing in this file and still
can not get your Darkbot running, feel free to join #Darkbot on the Darkbot
Network, and we will do our best to help you. Keep in mind that we are not
there to set up and run your bot for you. One or two questions about commands
are okay, but if you have to ask about every command, then maybe you shouldn't
be running a bot.
Note: There are many builds of Linux out in the world today. The coders try and
build Darkbot to be run on as many as possible but some times it doesn't work
out that way. If there is a problem with compiling Darkbot on your Linux build,
please let us know. The same goes for other Operating Systems, Windows, Mac OS
X, BSD, etc. In particular, if make complains that it can't find source files,
try gmake.
Help can be found for Darkbot either by irc, or from our web page.
- Irc: Servers irc.freezedown.org, eu.undernet.org, us.undernet.org
+ Irc: Server chat.freenode.net
Channel: #darkbot
- Web page: http://www.freezedown.org Forum: http://www.freezedown.org/forum/
+ Web site: http://darkbot.sourceforge.net
We do not support any Darkbot code that has been downloaded from any site other
then the official one. Any code that has been modified by anyone other than an
official Darkbot coder, will also not be supported. (If you have a good idea
for a modification, please share it with us. If it makes the final code, you
will be given credit.)
###############################################################
Follow the order of events described here, and you'll have your Darkbot up and
running!
There are two ways to install Darkbot, from a git checkout, or from a source
tarball. If you are using git, make sure you have the usual autotools installed,
and GNU make (which might be called gmake for your operating system).
INSTALL FROM A SOURCE TARBALL -
Download to your shell compressed archive from -
https://sourceforge.net/projects/darkbot/files/
De-compress the downloaded archive (tar -zxvf *.tar.gz) -
tar -zxvf darkbot-8rc4.tar.gz
INSTALL FROM GIT -
Clone the git source repository from -
git clone git://git.code.sf.net/p/darkbot/darkbot darkbot-darkbot
FOR BOTH -
Change to the newly created directory.
BASIC CONFIGURATION -
For a basic configuration you can just run the build.sh script -
./build.sh
Which will start the build process, and install the result to $HOME/darkbot.
In that directory you will need to edit two files at least -
darkbot/var/servers.ini, change it to have the name of the IRC server/s you wish
your Darkbot to join.
darkbot/var/setup.ini, at the very least you should change BOT_NICK so that all
the Darkbots don't have the same IRC nick name. DEFAULT_CHANNEL should also be
changed to what ever IRC channel you want your bot to be in. None of the other
stuff really needs to be changed.
ADVANCED CONFIGURATION -
If you are using git, then run the autogen.sh script, otherwise don't. Change to
the build directory, then run -
./configure --help
We are not going into detail and repeating the instructions shown when you run
./configure, because they are self-explanatory. It's just the usual thing you
expect when using autotools configure scripts. Run the configure script again
with your chosen options, then "make" and "make install" as usual.
OFFLINE CONFIGURATION SETTINGS
(follow the samples in the files and don't leave any empty lines)
How to do it.
[userlist.db]
Adding users to Darkbot's user list.
Open darkbot\dat\userlist.db and check this sample line: '#*
*user@*.yourhostmask.com 3 0 mypass I need to use SETINFO' with your
information.
#* = (with asterisk) adds user to all channels; #channel1 adds user to channel1
*user@*.yourhostmask.com = is the mask of the user to add
3 = user level -- You should always be Darkbot's administrator (level 3) on your
darkbot\dat\userlist.db [Level 3 is the highest, allows you to control all
Darkbot functions; level 2 gives access to channel operation commands plus level
1 commands; level 1 only permits to manage Darkbot's database - it's the so
called helper level; all other commands are public, meaning everyone can perform
them].
0 = number of times Darkbot saw that user on the default channel
mypass = If you want to define a password for you can do it replacing 'mypass'
with user's one.
'I need to use SETINFO' = is a message Darkbot sends to newly registered users
in order to remind them to define or not it's greeting message. Leave it as is
or write, for example, "Hi Boss ;)". You can also replace 'setinfo' message with
a 0 (zero) to disable it.
(You can add more users from online with the !adduser command or delete with the
!deluser command)
[setup.ini]
Open darkbot\dat\setup.ini. See the SETUP file for more details.
This is the file you need to edit to setup your Darkbot's nickname, username,
realname, default channel to join, virtual host, command character prefix and
seen users switch. Change the contents of the file as you need overwriting
existing parameters. Do not remove anything before '='. Do not leave extra
spaces or lines. Do not use carriage returns. Save and exit.
Obs.:
'VHOST= ' to set your virtual host (must be a registered domain pointed to the
same computer as Darkbot and configured for IRC)
'CHAN=#ChannelHere' sets Darkbot's default channel. If you want to add
more channels use perform.ini.
'CMDCHAR= ' to set Darkbot's command prefix to trigger most of it's commands.
'NICK='This is the nick your bot will have when it joins irc, default is Darkbot
'USERID='This will be the name before the @ in the bots user host
'REALNAME=' This will be the info after your bots user host
'AUTOTOPIC='Automatically cycles channel's topic every 30 minutes. To turn
autotopic off, use "0" (zero) in place of the topic.
'SEEN='Turns seen on or off. 1= on, 0= off
[perform.ini]
Having Darkbot performing IRC commands automatically.
You can make Darkbot perform a list of raw IRC commands when it connects to the
server (as mIRC's perform function). You can make your Darkbot join other
channels, perform mode changes, login to channel services with it. Depending on
each network, your IRC knowledge and your imagination depends the commands you can
add.
Open and edit darkbot\dat\perform.ini. Write one command per line.
Examples:
- to join an additional channel besides default one
JOIN #Channel_here
- to set modes
MODE #Channel +nt
- to set a topic as soon as enters a channel
TOPIC #Channel_here :this is a test topic
- to send a message to you as soon as it connects
PRIVMSG YourNick :hey... I'm here
- to send a notice to you
NOTICE YourNick :be ready to feed me :p
- - to authenticate on Superchat.org
- PRIVMSG serv@superchat.org :login #darkbot blahblah
+ - to authenticate on Freenode's Services
+ PRIVMSG NickServ :IDENTIFY username password
- to authenticate on Undernet's CService
PRIVMSG x@channels.undernet.org :login username password
- - to have bot X giving op to your Darkbot
+ - to have bot X giving op to your Darkbot on Undernet
PRIVMSG X :op #channel_here username
- to login and get Ops on a eggdrop
PRIVMSG Eggdrop_nick :op password #channel
General rule to send raw IRC messages is preceding the message with ':'. However
there are situations where you might be able to perform commands without it.
- to identity your Darkbot on some servers
NICKSERV IDENTIFY darkbot_password
- for some channel services
CHANSERV OP #channel_here Darkbot
[deop.ini]
Changing Darkbot's behavior when is not Op.
You can have your Darkbot perform commands when it loses channel Op like messaging
you, automatically asking Op to the channel service or another bot or Ops. Open
and edit darkbot\dat\deop.ini. Check the examples below. Leave this file blank
if you want it to do nothing. (see also examples used on perform.ini)
PRIVMSG #channel_here :Hmm, wish I had ops...
NOTICE Your_nick : I lost Ops :(
- PRIVMSG x@channels.undernet.org :login username password
+ PRIVMSG NickServ :IDENTIFY username password
- PRIVMSG X :op username
+ PRIVMSG x@channels.undernet.org :login username password
- PRIVMSG serv@superchat.org :login #darkbot blahblah
+ PRIVMSG Network_Channel_Service_Here :op username
chanserv op #channel_here Darkbot
PRIVMSG Eggdrop_nick :op password #channel
[servers.ini]
Changing or adding servers to Darkbot.
- By default Darkbot connects to one of UnderNets servers
- us.undernet.org 6667
- eu.undernet.org 6667
+ By default Darkbot connects to one of Freenode servers
+ chat.freenode.net 6667
+ irc.freenode.net 6667
Open and edit darkbot\dat\servers.ini. You can list as many servers as you want,
so if it's disconnected, it'll switch to others. Do not leave empty lines. Do
- not mix servers, like us.undernet.org and dal.net. Save and exit.
+ not mix servers, like freenode.net and dal.net. Save and exit.
GOING ONLINE
Write on your shell './darkbot' in order to have it connect to the Internet.
Wait a little bit and if you didn't change servers.ini in order to use another
- network, Darkbot will join channel #Darkbot at Undernet.org. (To join this
- network type in your IRC client /server us.undernet.org and /join #darkbot)
+ network, Darkbot will join channel #Darkbot at Freenode.net. (To join this
+ network type in your IRC client /server chat.freenode.net and /join #darkbot)
If you did change the servers.ini and the CHAN= in the setup.ini then Darkbot
will join that server and channel that you set there.
If another nick Darkbot is already there, your Darkbot will take nick Darkbot0,
Darkbot1 etc. (You can see which one is yours by doing /whois and looking at the
output info. It will have the same hostmask as yours or the machine where it is
running).
You can have Darkbot jump to another server by performing !JUMP command.
Setting or changing the password to access Darkbot (25 characters maximum). If
you didn't change 'mypass' on userlist.db write
/msg Darkbot pass mypass my_new_pass.
After changing it you'll receive a notice like this:
-- Password for youruserid@yourhostmask.com has been updated.
Login to Darkbot:
Now you have to authenticate yourself to Darkbot to perform some commands. To do
so type
/msg Darkbot LOGIN YourPass
You'll receive a notice like this from Darkbot:
-- Verified: #darkbot[3]
Notes: have in mind - for security reasons - if you or Darkbot leaves the channel
you have to login again when returning.
ONLINE ADDITIONAL CONFIGURATION SETTINGS
Set greeting message
If you want Darkbot to greet you when you join the channel and you didn't
already edit it in the userlist.db 'I need to use SETINFO' type, for example,
!SETINFO I think I know you ;P
(!setinfo 0 disables the function; typing !setinfo without any parameters gives
you some help about the command)
Next time you join the channel Darkbot will greet you with that mesage.
Set Darkbot's nick name
In order to have Darkbot with a nick you like, you only need to type,
!SETNICK MyDarkbot
Set userid
If you want to change Darkbot's user id type,
!SETUSER newuserid
Set default channel
To instruct Darkbot what channel must be the default one, type,
!SETCHAN #YourChannel
Set Command Character
If you want to change the default command prefix [ ! ] issued to Darkbot to
execute some commands and, for instance, you want to use command character '>'
type,
!SETCHAR >
Set auto topic
Auto-topic function makes Darkbot repeat channel's topic you specify every 30
seconds (default). To do so type, for example,
- !AUTOTOPIC Visit http://www.freezedown.org for complete Darkbot
-information.
+ !AUTOTOPIC Visit http://darkbot.sourceforge.net for complete Darkbot
+ information.
Set virtual host
If you want to set a virtual host to Darkbot type (must be a registered domain
pointed to the same computer as Darkbot and configured for IRC)
!VHOST your.vhost.com
--**--
The remaining files within the \dat folder can also been edited offline. info2.db
(stores topics and corresponding replies), randomstuff.ini (stores random
replies), seen.db (stores the list of users seen by Darkbot) and perbans.db
(stores permanent bans)
START ADDING TOPICS
As all commands in this document YOU MUST LOGIN (/msg BotNick LOGIN yourpass)
before you can execute any Darkbot's command)! Also, you need to read the complete
command list document where you find a more detailed explanation about each one.
This is only a superficial help file to get you to add, modify and delete basic
topic replies.
Login to your Darkbot
Type:
YourBotNick ADD hello hello N~
(now type 'hello' and Darkbot will reply 'Hello YourNick')
Type:
YourBotNick MODIFY hello Hi N~, thanks for coming to C~
(now type 'hello' and the Darkbot's reply was modified to 'Hello YourNick,
thanks for coming to #YourChannel')
Type:
YourBotNick DELETE hello
(Darkbot deletes the topic 'hello'. If you type hello he don't answer)
YOU MUST READ
Darkbots Commands List and all help documents. This is only a short
file to get your Darkbot up and running.
------------------ " -------------------
OTHER FILES
info2.db - This is the information your darkbot learns and replys to when asked
questions. It's the main database.
A topic can be more than one word, but will be separated with +'s instead of
spaces. If a data starts with a +, the reply will be in the form of an action.
If the data starts with a -, the output can be stacked using PIPES and you can
use raw data, to do things such as NOTICE, PRIVMSG and even KICK. The symbol "^"
is the $nickname variable. The ^R (reverse control char) is the $chan variable.
While this may seem a bit confusing... don't worry about it, It's very simple,
just hard to explain in words without SHOWING you the bot in action.
randomstuff.ini - List of random things to say. You can add more online by
saying: BotNick RANDOMSTUFF information to add.
permbans.db - This is a text file, just a .db (database) file name extension.
Use the !PERMBAN and !DELBAN commands from on-line to add\delete.
seen.db - This is a list of people your bot has seen. You can access it with
!SEEN , seen's over one week old are deleted.
SOMETHING WRONG
All suggestions here are proved to work on several linux flavors and several
machines. Although we believe there are no side effects to your computer or to
yourself in doing it, follow them at your own risk. Do not blame your Darkbot in
case he decides not answering you.
(A) - Before proceed:
- Turn off your Darkbot by issuing command 'kill' (do ps x to see Darkbot's
process id and kill -9 pidNumber or killall darkbot)
(B) - Always make a backup of the file you want to work with before any change
or make a copy of Darkbot's folder using command 'cp'. Leave the file or 'Copy
of darkbot' as a safe backup in case you need to restore a file, you already have
it.
(C) - Use linux text editors if you can to edit Darkbot files. If you can't use
another text editor; the one you are using might be adding hidden codes or
changing the format of the original files. Check if file extension is the same.
For instance, if you are using Windows Notepad and file userlist.db extension
after editing and saving is userlist.db.txt rename it to userlist.db.
(D) - Do not leave empty lines on the middle of others or on the end of the
text.
============================
A Few F.A.Q's
I can't read and edit some files that have kind of strange black squares. Is
that Code Black virus?
-Darkbot is done in a way that is very safe in all aspects not only on IRC but
also on it's invulnerability to virus or trojans. So no, it's not any virus or
nothing like that. Those are codes left by your editor when tabs and carriage
returns are used. Looks like you are editing those files in Windows so use
Wordpad. You can also use Notepad but in some files you need to reconstruct the
lines in a way of having each command line on a separated line. Never leave
empty lines.
My Darkbot don't connect at all.
- Run Darkbot with minimal configuration (no hand editing at all) to see if
- connects to Undernet.org and goes to channel #darkbot. If you go there, Darkbot
+ connects to chat.freenode.net and goes to channel #darkbot. If you go there, Darkbot
should react with a short answer if you write it's nick.
- if not, install Darkbot again from the original compressed file. If problem
persists your original compressed Darkbot file or some of it's contents might be
corrupted so download it again from Darkbot's official site.
My Darkbot don't recognizes me when I /msg Darkbot login mypassword.
- After following procedures on (A) add yourself to darkbot\dat\userlist.db -
Save and exit - Connect Darkbot again and try to /msg Darkbot login
yourpassword.
- if Darkbot notices you as accepting your login, write on the public window
'Darkbot add test 123'. Darkbot should answer 'Okay'. Write 'test'. Darkbot
should answer '123'.
- if not, follow procedures on A, B, C and D.
- if Darkbot is still not accepting your login
- Open your darkbot\dat\userlist.db
On the sample line '*user@*.yourhostmask.com 3 0 mypass I need to use SETINFO'
You only need to overwrite *user@*.yourhostmask.com and 'mypass' in order to get
your Darkbot online and access to it.
The mask *user@*.yourhostmask.com should match the one you have when you connect
to the same network where your Darkbot is (do /whois to_ yournick to compare
it). You must use a wildcard * on all portions of the mask that change in every
time you connect. General concept is you should substitute all changing items on
your mask with an asterisk (*).
- While connected do /whois YourNickHere and check the first line of the output.
On the userid/ident side (the one on the left of @) you must use one * right
before of it on your userlist.db entry. If that ident has a leading ~ don't use
it. ~myident@blah.blah.blah or myident@blah.blah.blah should go to userlist as
*myident@blah.blah.blah. If your ident changes at times (some characters are
missing like this ~myid@blah.blah.blah) on the right side, right before @, use
the wildcard on both ends, i.e., *myid*@blah.blah.blah.
On the IP address side, right of @, compare what you have with the examples
bellow.
Static IPs (never changes):
- if your IP looks like this: myident@myhost123.mydomain.com
you shoud add as *myident@myhost123.mydomain.com
- if your IP looks like this: myident@11.222.12.123
you should add as *myident@11.222.12.123
Dynamic IPs (changes with each connection):
- if your IP looks like this: myident@myhost123.mydomain.com and the portion
that changes for every connection is '123'
you'll add *myident@myhost*.mydomain.com
- if your IP looks like this: myident@11.222.12.123 if the portion that changes
for every connection is 12.123 you'll add *myident@11.222.*
My Darkbot don't connect to the servers I want.
Write on darkbot/scripts directory ./AddServer and follow instructions
or
- follow procedures on A, B, C and D.
- open servers.ini and remove the servers in there adding those you would like
Darkbot to connect to. Syntax must be .irc.server.here 6667' and NOT
irc.server.here:6667' . Save and connect.
My Darkbot is not giving me the greeting message (setinfo).
Darkbot ignores whoever rejoins a channel for a period of time. The default
length of time to not recount someone when rejoins the channel is set to 60
seconds.
My Darkbot is not accepting commands if I repeat them in a short period of time.
Darkbot ignores for a certain period of time repeated commands to avoid
flooding. Use one command alias or wait a couple minutes.
My Darkbot is not answering when someone asks the same question.
Darkbot will not reply to a topic already asked (with same syntax) during a
certain period. By default that length of time is set to 5 seconds.
I'm stuck... I don't know how to turn off my Darkbot
You can use command !die online or on your shell kill -9 pidNumber after doing
'ps x' do check it's pid, or killall darkbot.
// ================ SYSTEM REQUIREMENTS ================
/*
* Change the Ansi C signal handling below if it's not in the standard place,
* usually on include/. Leave it as is if you don't know what that is. Type
* 'man signal' on your unix box for more info.
* (default = <signal.h>)
*/
#include <signal.h>
/*
* If you are getting errors during compilation about clock_t
* and clocks_per_sec not being available, turn this option ON.
* This includes <time.h> in addition to <sys/time.h>.
* (default = OFF)
*/
#define NEED_CLOCK_T ON
/*
* If your compiler does not support snprintf() turn this
* option ON. (default = OFF)
*/
#define SNPRINTF_SUPPORT ON
/*
diff --git a/docs/README_UTILS b/docs/README_UTILS
index 5500f9c..5f89313 100644
--- a/docs/README_UTILS
+++ b/docs/README_UTILS
@@ -1,373 +1,373 @@
:::WARNING::: Do not use these script with darkbot they need updated.
Shell Utilities Help
All shell utilities mentioned here with exception to 'configure' must be
in /scripts directory.
-For support, malfunctions, suggestions, please visit our forum.
-http://forum.freezedown.org
+For support, malfunctions, suggestions, please visit
+http://darkbot.sourceforge.net
----------------------------------------------------------------------
AddServer
AddUser
check-integrity
configure
convertdb (not a shell utility)
dbcron
download-databases
kill.darkbot
live-update
restart.darkbot
----------------------------------------------------------------------
###########
AddServer #
###########
Basically what this script does is managing your servers.ini file by adding
removing and changing servers and ports.
You have the option of manipulating only your local servers file or downloading
an updated server list from the International Federation of IRC and work with
those servers.
On all lists the servers are preceded by a number (which is not in fact part of
the files) to help you better choose or manage each entry.
On the remote servers list the ports displayed on the right are only for your
reference and corresponds to all available ports. It's recommendable to select
option 2 on the menu to load the external servers before changing local ports
so you'll have updated information to deal with.
If you decide to move all remote list to your local file, port 6667 will be
used for all servers. You can later change that port for each server on the
main menu, option 8.
On all lists PgUp/Down or arrow keys scrolls the text; Q quits from the list.
CTRL+C aborts at all times.
To launch the utility write ./AddServer. For a quick server entry write:
./AddServer server port (ex: ./AddServer irc.server.here 6667 )
----------------------------------------------------------------------
#########
AddUser #
#########
Manages user access on Darkbot
This utility displays, adds and removes user entries on your userlist.db file.
Usage: AddUser [-option|s]
To launch the utility and go to it's menu write $0
For a quick user entry write:
./AddUser userid@host level
Ex: ./AddUser *whateverid@*host.domain.net 2
(It will add an user with access level 2 to all channels).\n
./AddUser -h Shows this help information
While displaying file contents all entries are preceded by a number (which is
not in fact part of the files) to help you better choose or manage each user.
If the entries goes over screen size ( as this help text for sure will ) use
arrow keys or PgUp/Down to scroll and type Q to quit, or scroll the list to
it's very end so it will automatically exit and proceed to the next function.
CTRL + C aborts at all times.
How userlist.db is composed... How to enter values...
dat/userlist.db is the file where all user access records are stored.
Every entry should have:
<#channel(s)> <userid@host> <seen user> <level> <password> <greeting message>
When entered online the command line should be:
!ADDUSER #channel *userid@host.domain level 0 (where level must be 1,2 or 3)
- Channel field can be:
#* - it gives user access to all channels
#channelABC - it gives user access to #channelABC only
#channel1,#channel2,#etc - it gives user access to #channel1,#channel2,#etc
- On the user id field
correct - *userid (or) *useri*
not recommended - userid (or) *
incorrect - ~userid (or) *!*userid (or the use of ! and ~ anywhere)
- On the host field
Static IPs (IP never changes) - You should use it as is, i.e.:
if your IP is like this ...
myhost.123.mydomain.net
myhost.mydomain.net
11.222.12.123
... you can leave it as they are.
Dynamic IPs (IP is different on each connection)
You must use asterisks (*) and/or question marks (?) on the changeable areas
Examples:
on : myhost.123.mydomain.net
use: myhost.*.mydomain.net (or) myhost.???.mydomain.net
on : myhost.mydomain.net
use: *.mydomain.net
on : 11.222.12.123
use: 11.222.12.* (or) 11.222.*
Host Masks can NOT have spaces or any other characters or symbols besides the
ones mentioned above.
- Seen field
Starting as default value of 0 it will increase with the times Darkbot sees
the user accessing it's channels.
This field is automatically generated by Darkbot so no user intervention
is needed when adding an user online.
- Level field
User levels allowed are:
1 = Database Management commands
2 = Channel Operation + Database Management commands
3 = Administrator - All commands
- Password field
When added online trough the !ADDUSER command or entered directly on the file
for the first time while adding an user should be a zero (0).
When the user issues the online command /msg Darkbot pass 0 new_password
the new password will be encrypted on the file (on latest releases).
Be aware however if you have on defines.h LOGS activated, the message issued
by the user to Darkbot will not be encrypted. Turn LOGS off if you don't
want that to happen.
- Setinfo field
It will have a default message like 'I need to use !Setinfo'. When any
value entered could have a 0 (zero), which deactivates the function, or a
greeting message Darkbot displays when the user joins a channel.
You can see a short help online by typing !SETINFO
----------------------------------------------------------------------
#################
check-integrity #
#################
Checks all dat files for common mistakes/errors
Darkbot must be offline for most of saved information be effective.
Usage: <file|s|all> [-option|s]
Examples:
./check-integrity all
./check-integrity info2 userlist
./check-integrity all -nointro
./check-integrity random perform -nointro -quick
./check-integrity -report
Available command line triggers for files are:
all; info2; servers; setup; perform; userlist; random
(all checks all files; random checks all files with random entries)
Available command line triggers for options are:
-quick Speeds up the process bypassing pauses (sleep instances)
-nointro Bypasses introductory information *
-report Shows report file contents
-topicsize sets info2.db's topic length (default 50) *1
-replysize sets info2.db's reply length (default 400) *1
-default Returns program to it's default values removing all options
-h Shows a brief usage help
* The values of these options will be retained unless you use -default
*1 This setting is only necessary if you are using a different length
then the one defined on defines.h file
To trigger a parameter write ./check-integrity followed by one or as many
files or options you want.
- All operations are done on a working temporary file, leaving it's original
intact.
- All removed items/entries from any file are recorded on the report file.
- No files are definitely saved after changes without a prior bakup being made
on the original directory.
- This is a non interactive utility, i.e., no user intervention is needed.
However, all steps of the process are paused during up to 5 seconds so
the user can follow it's progress by reading it's messages. If the user
wants to speed up the process option '-quick' must be used at command line
so all sleep/pause instances will be bypassed.
Main Features
Line Feed check - verifies if there is a line feed at the end of files
Empty Lines - Cleans all empty lines wherever they are on the files
Incomplete Entries - Checks if there are topics with no replies on info2
Duplicate Entries - Checks for repeated lines on some files
Duplicate Topics - Checks for duplicate topics on info2
Topic Length - Checks if topic length on info2 is under the limit
Data Length - Checks if data length on info2 is under the limit
RDBs check - verifies if there are RDBs on info2 without links to files
and files on dat directory wihout RDB links
Random Files - Checks if total number of random entries is correctly
posted on the first line on randomstuff.ini, random.ini and all
RDB files or removes it in case local version is RC4 or later.
Setup.ini - Checks syntax; misplaced spaces; missing values
Servers.ini - Checks syntax; missing ports
Perform.ini - Default checks (empty lines and line feed)
Userlist.db - Checks for missing '#' on channels field; missing or
incorrect IPs; incorrect leading '~' and '*!' or missing '*' on userid
field; user levels; seen field; password field; setinfo field
This utility executes a considerable amount of operations during
file integrity verification. It depends on the size of the files
to be checked and errors to correct the time it takes to perform
all it's functions with accuracy.
All process is done without user intervention, so be patient and
wait until it is done or leave it working and check afterwards
it's final results on the integrity-report file or by typing
./check-integrity -report
If you are in a rush type ./check-integrity -quick
If you get wrong results on final counts due to unpredictable
characters or symbols you might have on your files please help
-us correct the problem by participating it on the forum.
+us correct the problem by participating it on the official site.
To abort all operations at any time press CTRL + C
----------------------------------------------------------------------
###########
configure #
###########
Goes over all basic configuration of your Darkbot.
You must run this script when on first installation of Darkbot.
----------------------------------------------------------------------
###########
convertdb #
###########
(Not a shell utility)
Syntax: ./convertdb -convert
It converts old Darkbot versions userlist.db passwords (prior to series 7.0)
into an encrypted format.
You have copied your pre 7f0 userlist.db in to the dat directory
DO NOT use this utility if You have created a brand new darkbot, and have no
users.
All users added with this script will have a password of 0
and should set their new password on IRC by issuing the command
/msg Darkbot pass 0 new_password.\n
Be aware if you are logging private messages the encryption
will not cover them, making it possible to see passwords
on the logs. So turn logs off on defines.h if you don't want
that to happen.
The file on scripts directory it's already compiled. However, if you
compile it's source on a non cygwin environment it's bin should
be placed on scripts directory and being so userlist relative path
should be "../dat/userlist.db" and "../dat/temp.db".
Under cygwin the executable should be placed on Darkbot's root dir
due to the necessity of cygwin dynamic library.
If that is the case read the instructions and edit source/convertdb.c
----------------------------------------------------------------------
########
dbcron #
########
Utility to auto generate crontab job on Darkbot checking if it is connected
during a cycled period of time.
When you first run it a new file is created overwriting original one and
the actual cron working engine is installed and it will remains active,
providing it's path and Darkbot's path remains the same.
If for any reason you've changed your Darkbot directory or it's binary
you'll need to modify the variables DBPATH DBBIN and DBPIDFILE on top of
the newly created file accordingly to the actual values.
Defaulty crontab job is of 10 mins interval. If you wish to change it
edit '0,10,20,30,40,50 * * * *'. If you don't understand it type 'man crontab'
How main engine works:
Changes to darkbot root dir; if pid file exists extracts pid number;
tests it by issuing an inoffensive kill; if pid is active exits, doing
nothing; if not means the file with pid is there but there is no active
process, so removes it. finally cheks if program bin exists then starts it.
----------------------------------------------------------------------
####################
download-databases #
####################
Downloads available pre made database files from Darkbot's site.
After download is made to your computer the pre-made database(s) will be
installed definetely on info2.db file after a series of integrity checks
done in conjunction with check-integrity utility.
----------------------------------------------------------------------
##############
kill.darkbot #
##############
Kills Darkbot pid
----------------------------------------------------------------------
#############
live-update #
#############
Updates local Darkbot files directly from Darkbot site
Program Usage:
./live-update [OPTION]
./live-update: (with no option) executes the program
./live-update -u Undo last changes
./live-update -n News - (latest news usually related to updates)
./live-update -v (v0, v1, v2) Verbose mode.
./live-update -h Help info (this one)
./live-update -o Turns Live Update ON or OFF
NOTE: - By switching live-update OFF you'll not be able to receive
live updates!
- Settings for verbose are 0=Stealth/silent; 1=Minimal messages
(default - no prompts if no updates present); 2=all available
program messages.
This script checks if there is any news update, pre-made database
or a most recent code release by comparing the contents of local
installation with the information obtained from the site.
In practice this utility starts by checking program integrity -
- if it passes goes to Darkbot site and downloads a piece of code
which contains the updates ids - those ids are compared with the
information stored locally - then checks if there is any news you
should read.
At the same time compares the installed code with most recent one -
- if there is necessity of code updates then patches all files with
the most current one, backing up all modified files. The update will
be done file by file on the same installation or by creating a new
directory with the name of the new release id on $HOME/darkbot-Ver
directory. Previous data files on dat directory are transferred to the
new installation. Old dynamic files like defines.h or darkbot.c are
transferred to the newly created source directory, with extensions .OLD.
The utility checks also if there is any new pre-made database in
conjuction with download-databases engine.
If the user wants to reverse (UNDO) the update process could do so with
the command ./live-update -u (not affecting downloaded databases).
A backup of all modified files/dirs is kept on .scriptutils/liveupdate/
working directory for the engine (do not remove it).
When typed ./liveupdate and nothing happens means there are no updates.
To do:
- automatic update of the new defines.h file;
- this utility being also integrated on a shell GUI.
Be advised that if you change Darkbot version from source files this
utility will not work. There is no reason to waste time and bandwidth
on an adultered program. The same will happen if you move or remove
source files from their original locations.
-For support, use the forum at http://forum.freezedown.org
+For support, check the the site at http://darkbot.sourceforge.net
----------------------------------------------------------------------
#################
restart.darkbot #
#################
Restarts Darkbot
diff --git a/docs/SETUP b/docs/SETUP
index d8c58d3..f602216 100644
--- a/docs/SETUP
+++ b/docs/SETUP
@@ -1,827 +1,826 @@
You can control how Darkbot works using setup parameters. You can
change these by directly editing setup.ini (when Darkbot is not running)
or by using the !set command (when logged in). In setup.ini it will
look like this -
PARAMETER=value
Using the !set command will look like this -
!set PARAMETER=value
Using the !set command will save your changes to setup.ini. Some of the
parameters will require a restart before they will be recognised.
Parameters are one of three different types, number, text, or boolean
(true or false). For boolean values you can use any one of these to
specify "true" - true, 1, yes, ack, ok, one, positive, absolutely,
affirmative, ah ha, shit yeah, why not. You can use any one of these to
specify "false" - false, 0, no, nack, nope, zero, negative, nah, no way,
get real, uh uh, fuck off, bugger off. Only the first letter is
important, so there are many variations.
NOTE: Some of these parameters can only be set at compile time. Exactly
which ones is currently subject to change, but they will all be
documented here in order to keep them in one place. This can look like
this -
sh build.sh --enable-parameter1 --disable-parameter2 --with-parameter3=value
================ LANGUAGE ================
PARAMETER LANG
DEFAULT 1
TYPE Number, Compile time
EXAMPLE --with-lang=1
Pick a number from the list below for the language you want your darkbot
to speak. Default is 1, English. The email address is the person
responsible for the translation.
------------------------------------------------------------------
1 = ENGLISH
2 = FRENCH - Inajira <inajira@videotron.ca>
- EfX <michel.efx@globetrotter.net>
- eCHaLoTTe <echalotte@cablevision.qc.ca>
3 = SPANISH - speed1 <speed@eduredes.edu.do>
4 = DUTCH - Asmodai <asmodai@wxs.nl>
5 = LATIN - Otaku <otaku@unixgeek.ml.org>
6 = GREEK - Chris_CY <chriscy@cylink.net>
7 = EBONICS - rapsux <bitter@ici.net>
8 = PIG LATIN - Cloud <burtner@usa.net>
9 = RUSSIAN - KOI8 encoding
10 = RUSSIAN - CP1251 encoding
- Oleg Drokin <green@ccssu.crimea.ua>
-11 = PORTUGUESE - Pincel <Pincel@darkbot.info>
+11 = PORTUGUESE - LuizCB <LuizCB@users.sourceforge.net>
12 = GERMAN - C.Hoegl@gmx.net & marc@reymann.net
13 = ITALIAN - daniele nicolucci <jollino@icemail.it>
14 = CHINESE - James <jamespower@263.net>
15 = SWEDISH - Ybznek <sunmo@seaside.se>
16 = NORWEGIAN - [SoHo] <soho@int19h.com>
17 = ROMANIAN - Radu <radu.negoescu@sante.univ-nantes.fr>
18 = ARABIC - MrSiMo <mrsimo7@yahoo.fr>
19 = TAIWANISH - ?
------------------------------------------------------------------
-? = Email juice@freezedown.org if you want to help add other langs!
------------------------------------------------------------------
================ STARTUP, CONNECTION, IRC ================
==== ON START ====
PARAMATER ENABLE_VERSION_CHECK
DEFAULT false
TYPE Boolean, Compile time
EXAMPLE
Your darkbot tell you (at startup) what the latest version of darkbot
is. We recommend keeping this disabled.
==== ON CONNECTION ====
PARAMATER VERB
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
Print out extra details while starting up?
PARAMATER CHECK_STONED
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
Check if servers are not responding, is so connect to next server in
list. (recommended) Some linux systems have problems with this. You'll
know if you're one of them if your bot disconnects every 5 minutes.
ALSO NOTE: If your bot seems to disconnect every 5 minutes, try turning
off CHECK_STONED.
PARAMATER CONNECT_WAIT_TIMEOUT
DEFAULT 10
TYPE Number
This is the time that darkbot will wait for a connection to the server,
before trying the next server. You may need to increase this if you are
on a slow connection.
==== ON CONNECTED - IRC ====
PARAMATER PERFORM_TIMER
DEFAULT true
TYPE Boolean
Send everything that's in PERFORM.INI to the IRC server every 60
seconds? Useful if the bot is banned, or X was split at the time darkbot
signed on.
PARAMATER DEFAULT_UMODE
DEFAULT "+i-ds"
TYPE Text
What user modes do you want for darkbot?
==== ON IRC ====
PARAMATER CTCP
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
Reply to CTCP's? (PING/VERSION).
PARAMETER ANTI_IDLE
DEFAULT false
TYPE Boolean
Want your darkbot to always have less than 10 min idle? This isn't
usually needed since darkbots tend to talk a lot.
==== ONJOIN ====
PARAMATER DISPLAY_SYNC
DEFAULT false
TYPE Boolean
When bot joins a channel, sometimes it's hard to tell when it's "synced"
and is no longer processing stuff -- this tells the channel the bot has
finished syncing. For example, if you try to login while it's still
syncing, it may just ignore your login request until it sees you in the
channel.
================ DATABASE MANAGEMENT ================
==== ON START ====
PARAMETER SORT
DEFAULT false
TYPE Boolean
Sort your info2.db on startup? Will take forever if u have a large db.
If you have dividers or any sort of markers on your database and you
want to preserve their position leave this directive undefined. Sorting
the database will put all items listed in alphabetic order.
PARAMETER FIND_DUPS
DEFAULT false
TYPE Boolean
When user's do the INFO command, and at startup, do you want to find and
remove duplicates database entries?
PARAMATER SAVE_DUPS
DEFAULT true
TYPE Boolean
When duplicate topics are found, do you want to save them? (in case some
topics are accidently deleted).
==== PERMISSIONS ====
PARAMATER GENERAL_QUESTIONS
DEFAULT true
TYPE Boolean
Do you want Darkbot to answer questions that match a topic without
addressing the bot?
PARAMATER ALLOW_ADD_IN_MSG
DEFAULT false
TYPE Boolean
Turn this on if you want to be able to use the ADD function in private
message to the bot.
PARAMATER ALLOW_DEL_IN_MSG
DEFAULT false
TYPE Boolean
Turn this on if you want to be able to use the DEL function in private
message to the bot.
PARAMATER MSG_RESPONSES
DEFAULT false
TYPE Boolean
If you want your bot to be able to respond to things asked in private
messages, turn this option on. Use the above two defines to allow /
disallow adding or deleting entries in private.
PARAMATER ENCRYPT_PASSWORDS
DEFAULT false
TYPE Boolean, Compile time
EXAMPLE
Toggles the use of encrypted passwords in the userlist.db file. Turn
this off if you don't want your passwords encrypted. Also note that if
you're using encrypted passwords and you decide to turn this option
off, you'll need to redo your userlist.db file. Note: If you're new to
Darkbot, you may want to turn this option off.
PARAMATER REQ_ACCESS_ADD
DEFAULT true
TYPE Boolean
Minimal access level required to add topics?
PARAMATER REQ_ACCESS_DEL
DEFAULT true
TYPE Boolean
Minimal access level required to to delete topics?
==== LOGS ====
PARAMATER LOG_ADD_DELETES
DEFAULT true
TYPE Boolean
Do you want to log who adds/deletes topics? Log saved to
dat/logs/add_delete.log.
PARAMATER LOG_PRIVMSG
DEFAULT true
TYPE Boolean
Do you want to log all privmsg's to your darkbot? (will be saved to
dat/logs/ dir).
==== SLEEP DIRECTIVES ====
PARAMATER SLEEP_LEVEL
DEFAULT 3
TYPE Number, Compile time
EXAMPLE
Level at which user's can make darkbot shut up (aka hush). This is
useful for help channels when they want darkbot to quit talking while
they address something important in the chan.
PARAMATER SLEEP_TIME
DEFAULT 300
TYPE Number
How many seconds to sleep for?
PARAMATER GOSLEEP_ACTION
DEFAULT "\1ACTION falls asleep... ZzzZZzzZZzz\1"
TYPE Text
PARAMATER WAKEUP_ACTION
DEFAULT "\1ACTION wakes up from a snooze..\1"
TYPE Text
What you would want your Darkbot to say when sleep and wake up commands
are issued? (If you want you can change what is between 'ACTION' and
'\1')
==== DATA SIZE ====
PARAMATER MAX_DATA_SIZE
DEFAULT 400
TYPE Number, Compile time
EXAMPLE
The max length your database replies will be. This will be useful to
people loading their database into ram - if your data is all less than
400 chars, then you can save some ram.... Longer replies allows you to
do more, for example, with bitwise operator PIPE.
PARAMATER MAX_TOPIC_SIZE
DEFAULT 50
TYPE Number, Compile time
EXAMPLE
The max length your database topics will be.
==== OUTPUTS - TIMERS ====
PARAMATER LASTCOMM_TIME
DEFAULT 5
TYPE Number
LASTCOMM_TIME is the length of time (in seconds) that your bot will not
reply to a topic already asked. Thus if someone asked your bot about
"mirc" that question could not be asked again in the same format for N
seconds (or till the question is out of buffer). This prevents the bot
from falling prey to users who like to repeat.
PARAMATER OUTPUT1_COUNT
DEFAULT 4
TYPE Number
PARAMATER OUTPUT1_DELAY
DEFAULT 1
TYPE Number
PARAMATER OUTPUT2_COUNT
DEFAULT 6
TYPE Number
PARAMATER OUTPUT2_DELAY
DEFAULT 2
TYPE Number
The output timers. Darkbot does not output text without first putting it
into a queue list. If the bot has several lines of text waiting to be
sent, it starts to delay longer and longer between output, so it can't
flood itself off of IRC. Explanation:
If text in queue is < OUTPUT1_COUNT, output it. If text in queue is >
OUTPUT1_COUNT, delay OUTPUT1_DELAY seconds. If queue is > OUTPUT2_COUNT,
delay OUTPUT2_DELAY seconds. If number of text in queue is higher than
OUTPUT_PURGE_COUNT, then just delete all unneeded output (ie; any text
and notices, but leaving in stuff like kicks and modes) The defaults
below are recommended, as the bot isn't going to flood off. If you are
having the bot delete output messages and you'd like to increase the
queue, update the OUTPUT_PURGE_COUNT to a larger number. Just keep in
mind if someone floods your bot with a lot of VERSION requests, the bot
will sit there outputting a lot of version replies instead of deleting
them, causing it to act as if it's just sitting there not doing anything
when you ask it something in your channel.
PARAMATER OUTPUT3_DELAY
DEFAULT 3
TYPE Number
If still < OUTPUT_PURGE_COUNT and > OUTPUT2_COUNT then delay
OUTPUT3_DELAY secs.
PARAMATER OUTPUT_PURGE_COUNT
DEFAULT 7
TYPE Number
When all else fails... if more than OUTPUT_PURGE_COUNT delete them all!
No use in making the bot output slowly over a long period of time...
imagine if you set this to 50, and had an OUTPUT3_DELAY of 3 secs..
thats 50*3 secs till the bot is ready to output any new data to you!
======== OUTPUT MESSAGES ========
==== OUTPUT MESSAGES - ON TOPICS ====
PARAMATER EXISTING_ENTRY
DEFAULT "Sorry, there is an existing entry under keyword"
TYPE Text
Message to give when adding an existent topic.
PARAMATER NO_ENTRY
DEFAULT "I was unable to find entry:"
TYPE Text
Message to give when there is no mentioned topic.
==== OUTPUT MESSAGES - ON SEARCH ====
PARAMATER CANT_FIND
DEFAULT "Was unable to find"
TYPE Text
PARAMATER NO_TOPIC
DEFAULT "Sorry, I don't have any entry for"
TYPE Text
PARAMATER TRY_FIND
DEFAULT "What am I trying to find"
TYPE Text
These are the messages Darkbot will give on unaccomplished search
queries.
==== OUTPUT MESSAGES - ON NONEXISTENT TEXT ====
PARAMATER WHUT
DEFAULT "hmmm?"
TYPE Text
Answer to give in case Darkbot's nick is mentioned without any further
text.
PARAMATER RANDOM_WHUT
DEFAULT true
TYPE Boolean
Gives a random response from dat/whut.rdb instead what is specified on
'!set WHUT'.
PARAMATER DUNNO_Q
DEFAULT "*shrug*"
TYPE Text
Answer to give in case there is no reply on Darkbot's database.
PARAMATER RANDOM_DUNNO
DEFAULT true
TYPE Boolean
For those wanting the DUNNO_Q response to be random, turn this option
ON, and darkbot will ignore the default definition and use a random line
from dat/dunno.db
======== RANDOM STUFF =========
PARAMATER RANDOM_STUFF
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
Will read from a random line in dat/randomstuff.ini and say something
random in the home channel. ALSO if nothing is said in darkbot's home
channel it will say a randomstuff every RAND_IDLE as long as no one
says anything. (default = define) UNDEFining this directive will not
allow you to add RDBs or randomstuff entries. If you really want your
bot not to say anything from randomstuff.ini and keed adding random
replies, increase the time _TIME and _IDLE defines to, for example,
54750, which corresponds to 365 days :)
PARAMATER RAND_STUFF_TIME
DEFAULT 3600
TYPE Number
Time in seconds to randomly say something from randomstuff.ini.
PARAMATER RAND_IDLE
DEFAULT 1800
TYPE Number
Time in secs to say something in home chan when no one says anything.
This overrides the RAND_STUFF_TIME counter.
PARAMATER RAND_LEVEL
DEFAULT 2
TYPE Number, Compile time
EXAMPLE
Level at which user's can on-line add new randomstuff topics, this also
is the level at which users will be able to add RDB topics.
PARAMATER RANDQ
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
This is a new feature which enables the RANDQ channel command, which
will output a random quote from your randomstuff.ini containing the
specified search string.
PARAMATER BACKUP_RANDOMSTUFF
DEFAULT false
TYPE Boolean
This define backs up your randomstuff file every time you add a random
quote, in case you would like to do so.
================ IRC - CHANNEL RELATED ================
==== REGISTERED USERS ON JOIN ACTIONS ====
PARAMATER JOIN_GREET
DEFAULT true
TYPE Boolean
Have the bot do auto-greet (setinfo) to registered users?
PARAMATER SLASTCOMM_TIME
DEFAULT 60
TYPE Number
This is the length of time to NOT allow someone to be recounted when
they rejoin your channels, which tends to clutter up everyone's screen
with the setinfo. This basically keeps track of who joined in the last
___ seconds, and does not do their setinfo during that amount of time.
PARAMATER VOICE_USERS_ON_JOIN
DEFAULT false
TYPE Boolean
Have the bot VOICE users when they join?
PARAMATER OP_USERS_ON_LOGIN
DEFAULT false
TYPE Boolean
Have the bot OP users when they login?
==== USERS LOOKOUT ====
PARAMATER DO_WHOIS
DEFAULT false
TYPE Boolean
Want to be alerted when a user who joins is in "questionable" other
channels? This option only works on networks which their IRCD's allows
NOTICE to be sent using /notice @#chan.
PARAMATER MAX_LASTSEEN
DEFAULT 604800
TYPE Number
Max length in seconds to keep a lastseen (default = 604800 (7 days)).
PARAMATER SEEN_REPLY
DEFAULT "in the last 7 days."
TYPE Text
If you change the above time (MAX_LASTSEEN), be sure to update the
SEEN_REPLY to the respective time length.
==== COMPLAINT MESSAGES ====
PARAMATER COMPLAIN_REASON
DEFAULT "grrr, kick me again and I'm going to..."
TYPE Text
Message Darkbot will send to the channel where it was kicked from.
PARAMATER BITCH_ABOUT_DEOP
DEFAULT false
TYPE Boolean
will complain in the chan that the Darkbot is deoped in.
PARAMATER BITCH_DEOP_REASON
DEFAULT "grr, someone op me!"
TYPE Text
What do you want your Darkbot to say when is not oped?
==== CHAN OP DIRECTIVES ====
PARAMATER DO_CHANBOT_CRAP
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
Enable this if you want to make your darkbot bloated with stuff like
!KICK, !UP, !WACK, etc. Basically anything dealing with channel modes
and kicking commands. This includes PERMBANS. On linux, without this,
your darkbot bin will shrink considerably.
PARAMATER AUTOTOPIC_TIME
DEFAULT 1800
TYPE Number
Autotopic time interval in seconds.
==== KICKS AND BANS ====
PARAMATER DEFAULT_KICK
DEFAULT "Requested!"
TYPE Text
What do you want your Darkbot to say when kicks someone? Note when you
apply a kick with reason this setting will not overwrite it.
PARAMATER KICK_ON_BAN
DEFAULT false
TYPE Boolean
Kick people out when they are banned?
==== KICKS AND BANS - FLOODS ====
PARAMATER KICK_ON_CHANNEL_NOTICE
DEFAULT true
TYPE Boolean
Sometimes morons like to /notice flood channels. This define will make
the bot kick those people when they do a channel notice.
PARAMATER BAN_ON_CHANNEL_NOTICE
DEFAULT false
TYPE Boolean
If you want to take it a step further, you can also have the bot ban the
user@host too.
PARAMATER BAN_BY_HOST
DEFAULT false
TYPE Boolean
Finally, we can ban by *@host. This requires the above two to be turned
on.
==== KICKS AND BANS - DARKBOT'S OWN FLOOD PROTECTION ====
PARAMATER FLOOD_KICK
DEFAULT true
TYPE Boolean
Define this if you want your Darkbot to KICK out the people who flood
it. NOTE: This means flooding your BOT, not your CHANNEL. If you don't
define this, it will just ignore the user.
PARAMATER FLOOD_REASON
DEFAULT "Don't flood!"
TYPE Text
What do you want your Darkbot to say when someone is flooding it?
================ MISCELLANEOUS ================
PARAMATER WEBSEARCH
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
Web search feature.
PARAMATER METAR
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
METAR search feature.
PARAMATER WEATHER
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
WEATHER search feature.
PARAMATER TAF
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
TAF search feature.
PARAMATER QUIZ
DEFAULT false
TYPE Boolean, Compile time
EXAMPLE
Bot's online QUIZ.
PARAMATER QUIZ_TIMER
DEFAULT 25
TYPE Number
How long to wait before giving the answer?
PARAMATER QUIZ_REPEAT_TIMER
DEFAULT 20
TYPE Number
Don't allow another quiz until this time has expired (since the last
answer).
PARAMATER DO_MATH_STUFF
DEFAULT true
TYPE Boolean, Compile time
EXAMPLE
Do you want your bot to do math commands?
PARAMATER STATUS
DEFAULT false
TYPE Boolean, Compile time
EXAMPLE
Parse luser data? May cause SIG_SEGV on some ircd's (ie; non ircu)
Basically all this does is display network info like opers, servers, avg
# of users on the servers, etc.
================ AID DIRECTIVES ================
PARAMATER HELP_GREET
DEFAULT false
TYPE Boolean
Give user's who join a NOTICE with info on how to use the darkbot? I
don't bother with this anymore since my bot knows how to respond to most
general questions users ask. If your bot is new and doesn't know much,
then you may want to have it tell people how to use it.
PARAMATER AUTOHELP_GUESTS
DEFAULT false
TYPE Boolean
This define just sends a message to the channel, whenever a "Guest" user
joins, asking the user if they need any help. This is useful for help
channels.
If you change anything on the next 5 directives be careful not to remove
or change the position of '%s'.
PARAMATER L100(s,a,b,c,d,e,f)
DEFAULT S("NOTICE %s :I can be triggered by various \
forms of speech, all which must be addressed to me, in one of the \
following formats: %s %s %s or even %s .... In my database, you can \
find a topic by saying my nick, <topic> . eg; \37%s nuke\37 ..... \
to do a search on a word, or partial text, just type: <mynick>, search \
<text> ... eg; \37%s search nuke\37\n",s,a,b,c,d,e,f)
TYPE Text
EXAMPLE
PARAMATER L101(a,b,c,d)
DEFAULT S("NOTICE %s :I can also be triggered with even more \
human formats: \37%s who is bill gates?\37 .. You can also phrase it \
in a question: \37%s where is msie?\37 ...For more info \
-about me, visit http:www.freezedown.org\n",a,b,c,d)
+about me, visit darkbot.sourceforge.net\n",a,b,c,d)
TYPE Text
EXAMPLE
PARAMATER L102(a,b,c,d)
DEFAULT S("NOTICE %s :Welcome to %s, %s. Before \
asking your question, type %cHELP for a list of help topics.\n", a,b,c,d)
TYPE Text
EXAMPLE
PARAMATER mySetinfo
DEFAULT "My !setinfo variables are: ^ nick, % Number of joins, & \
Channel, $ user@host. Example: !setinfo ^ has joined & % times!! (also, if \
you make the first char of your SETINFO a \"+\" the setinfo will be shown \
as an ACTION)"
TYPE Text
EXAMPLE
PARAMATER myVariables
DEFAULT "data variables are: N~ (Nick), C~ (Chan), T~ \
(Time/date) B~ (Botnick), Q~ (Question asked), R~ (random nick), !~ \
(command char), S~ (current Server), P~ (current port) V~ (botVer), W~ \
(db WWW site), H~ (u@h), t~ (unixtime), BAN (sets a ban), TEMPBAN (bans \
for 60 sec)"
TYPE Text
EXAMPLE
Variables for the data replies.
diff --git a/docs/WHATSNEW b/docs/WHATSNEW
index da7f014..a729ee7 100644
--- a/docs/WHATSNEW
+++ b/docs/WHATSNEW
@@ -1,988 +1,988 @@
*******************************************************
Warnings, errors, malfunctions, code patches, suggestions
- Support Forum: http://www.freezedown.org/forum
+ Support: http://darkbot.sourceforge.net
(order is reverse-chronologic)
*******************************************************
Darkbot 8rc4: May 13, 2009
- Fixed DIE, NICK, METAR, PART, RANDQ, RANDQ2, RDB, STATS, TAR,
TELL commands crashing with no args. I made a small change to
the initial command parsing function which rendered some things
improper and made many functions crash because they were no
longer receiving the arguments they expected before the change.
- Fixed CHAR_INVOKE'd commands to do nothing if given too many
arguments.
- INFO2 command now outputs correctly in privmsg.
- Added the "You must specify a search string" message to
RANDQ and RANDQ commands with no arguments.
- Sleep command now checks for too many args, this is part
of the command structure now, so more commands are to follow
probably.
- MSG_INVOKE'd commands now also check for too many arguments.
- Commands with less arguments than expected now show
help messages again.
- Fixed crash error on ADDUSER command.
- Fixed retarded error in MEM command where I was trying
to change the contents of a const variable.
- Made OS, MEM, CMDCHAR, and CPU commands check for too many arguments.
- Fixed OS command on Windows.
- Fixed chanserv_random_stuff.
- Fixed alarmclock function.
- Fixed permbans command not outputting help for null
input. More to come.
- Fixed several commands that crashed not checking for
a null argument array. The fix I did looks sort of
retarded, but I found if i didn't check args[0] and args
both, it would crash on different command types.
Go figure. This fix works and I'll work on bettering it.
Darkbot 8rc4: April 30, 2009
- Fixed extensions.m4 file from discriminating against
me using a newer version of automake than 1.9.6, and
removed a few automake warnings.
- Fixed autotopic only using first word of input.
- Fixed crash on ADD command and probably others when msg
with no arguments.
Darkbot 8rc3: Sep 17 2008
- Fixed USERLIST and SETINFO commands crashing with no args.
There's probably more of these to come.
- Topics can now start with these commands that check for too
many arguments. Say you want to do:
dbtest add info+things hey N~, I don't have info on things.
Before this, a parsing error would invoke the "info" command.
This has been fixed, and the bot will now either not respond
to these inquiries if they don't exist in it's database, or
provide the desired reply.
- Added "too_many" parameter into the chanserv_command struct.
This specifies to the command parser if a command sent to the
bot should be checked for having too many arguments. This
particular change helps fix a number of issues which would
cause headache, and will be fine tuned more thoroughly when
I get the chance.
- More parser errors fixed. Added ILN in additon to ILC.
- add stats function now has subsequent call to free()
after the malloc() call. (Duh? What happened to that?)
- Fixed ILC. Oops on my part for breaking it.
- Part command no longer tries to output "I left the room"
message to the channel it parts.
- Updated TODO.
- Changed all command function parsing. Things should hopefully
work more correctly again.
- HLIST (Helperlist) command now allows multiple arguments.
For instead if you want to list all users level 3 and level 3,
you would do !HLIST 3 2.
- Fixed tell command to tell people about topics without having
do delimit them with '+' signs, so it runs like normal text now
for multi-word topics.
- Fixed sleep command. It now actually sleeps for the specified
amount of time, if any is specified.
- Part message now accepted as a parameter to PART command.
- More work on unixtime function. It now has more complex error
checking for strtol. More work on this to come.
- Renamed pluralize function to plural.
Darkbot 8rc3: Jan 16 2008
- Alarmclock function uses time_t variable now instead of long.
Also now accepts arguments specified in seconds.
- Bot no longer crashing during start if there's blank lines in
the servers file. It now ignores blank lines and comments
starting with '#' and '/'. If the server file is blank, it
aborts and tells the user to edit the file.
- Added pluralize() function for beautification purposes. See more
in general.c.
Darkbot 8rc2: June 07, 2007
- The STATS command, and all overhead produced by this command
can now be disabled during compile like so:
./configure --disable-stats
OR
./configure --enable-stats=no
- Changed the RANDOMSTUFF command to be a NORMAL_COMMAND, so you
can use this command with ADDRESS_INVOKE again (address the bot
directly).
- Added a little thing at the top of docs/WHATSNEW that indicates
which order the lines therein consist of according to when the
changes they represent were implemented. Made this sound more
technical than it should for no reason at all.
- If the input type is ADDRESS_INVOKE (the bot was called upon by
name), the bot responds anyway now, because it's going to output
an "I don't know" response if the topic doesn't exist. This doesn't
happen with DIRECT_INVOKE because the text may have been normal
channel conversation that was mistakenly parsed as a command.
- Commands which require 0 parameters now act accordingly again
when supplied with too many arguments. In other words, "dbtest
info things" would trigger the info command before. Now, it
uses check_existing_url and outputs a response if the topic
exists, otherwise, it just ignores it.
Darkbot 8rc2: December 09, 2006
- Updated server and user lists.
- More fixes to random whut.
- Tweaked random number generation.
- Consistant random number generation throughout the code.
Darkbot 8rc2: December 04, 2006
- Fixed some variable checking that was checking for integers
instead of bool values (random whut is fixed by this, flood
kick)
- Fixed Makefile.am file to produce DOS 8.3 file format
compliant config.h pre-file, and the copyright thingo
in the same file.
Darkbot 8rc2: October 11, 2006
- Fixed some divide by zero errors.
- Cleaned up the logging.
- Cleaned up the output of the build system.
- Cleaned up the parameter names.
- Cleaned up some help text.
- Script for building minimal darkbot.
- Disabled more channel code.
- Started documenting what darkbot works on.
Darkbot 8rc2: June 11, 2006
- Added docs/SETUP.
Darkbot 8rc2: May 31, 2006
- A busy month.
- Completed the autofoo.
- Added compat directory full of replacement functions for
when autofoo decides that the users OS is missing stuff.
- Added a testing mode for developers.
- Cleaned up most OS dependant things so that they now work
everywhere.
- Converted some defines.h things into ./configure --enable-X
--with-X=Y things.
- Added !set foo=bar infrastructure and command. The contents
of setup.ini is now under the control of generic, array based
code. To add things to setup.ini, just add them to the array.
- Added setup.ini parameters to the internal help system.
- Moved the rest of defines.h to setup.ini.
- General clean up and lots of minor things that get fixed in
passing.
- Added docs/HACKING.
- Re arranged some files.
- New building scripts.
- Darkbot and convertdb are much cleverer about finding the data
files.
- Cleaned up vars.c and vars.h.
- Have the help system deal with the command character as needed.
Darkbot 8rc2: May 04, 2006
- Cleaned generated files out of cvs and updated .cvsignore
files to match.
Darkbot 8rc2: Apr 21, 2006
- Added most of the help command summaries.
Darkbot 8rc2: Apr 19, 2006
- Fine tuned what commands can be done where. In particular
any password related commands can only be done in private
now.
- Made some commands behave consistantly no matter where they
are invoked from.
- Added HELP COMMANDS.
- Don't try to send oversize messages, split at a space.
Darkbot 8rc2: Apr 16, 2006
- Rewrote chansrv.c to use an array of pointers instead
of a huge if-else-if.
- Added patch from nak that stops ops from kicking
themselves via a topic kick.
- Added HELP <command>.
- Added isop <nick>.
- Added level <nick>.
Darkbot 8rc2: Mar 09, 2006
- Added !WEATHER <zipcode> command.
Darkbot 8rc2: Nov 07, 2005
- Fixed spelling errors, the word 'queue' was mispelled
throughout the code and in comments.
- I apparently broke show_banlist() a few releases back
trying to eliminate a type conversion warning, so it's
fixed again.
- B~ (bot nickname) variable can now be used in perform.ini
- OS command now works on windows.
- Fixed google command. A search string used to determine
successful replies was changed by google.
- Changed "ugly" message responses.
- Restart and rehash commands should now work on all operating
systems, including Windows.
Darkbot 8rc1: Mar 04, 2005
- Removed an unneeded line in main.c, that was used to "hide"
warnings on WIN32, which is a very bad idea.
- Changed check_dbtimers() so it ignores the CVS directory,
which contains information for the CVS server. This
fixes a situation that seems to have only presented itself
in FreeBSD, where it thinks the CVS directory is a
timer, and sends out random garble every few seconds.
- configure.ac and source/Makefile.am; very minor updates.
- Fixed randq, which I accidentally broke when adding the
-I switch. This also fixes some problems that turned up
on FreeBSD.
- Fixed a warning that came up in permbans.c about mixing
types when compiling on OS X. I changed %d on line 198
to %ud.
- configure now checks for clock_t.
- configure now automatically checks for snprintf, and
uses a replacement if it's not found.
- docs/INSTALL.txt is now INSTALL in the toplevel dir.
Another thing for automake to stop complaining about.
- The original configure script is now located in the
scripts directory, and is called "Setup".
- docs/contributors.txt is now called AUTHORS in the
top level of the distribution. Another thing automake
complains about. I also worked on the appearance of
this file, hopefully it looks a little better now.
- README.txt in the toplevel is now called "README".
Automake complains about this file also, if it's not
found.
- This file is now called ChangeLog, and has been moved
to the toplevel distribution dir. The reason for this
is that automake complains, if it can't find this file.
- configure now checks for the presence of windows.h,
and defines WIN32, if it's found. This removes the
need to do "make win". Until I add the noconsole
option again, you can run darkbot with no console by
doing "./darkbot &" in your cygwin shell.
- The configure.ac file is not yet complete, and most
of the definitions listed in config.h are not completely
implemented into the code yet. If you have problems,
please let me know, and these files will become completely
implemented as demand is met.
- Included premade Makefiles and configure script.
- Added "make convertdb", which will compile the database
conversion utility, which encrypts the passwords in your
userlist.db file.
- I added a Makefile.am in the toplevel, and in the source
directory. These files are used in conjunction with
GNU Automake to produce a Makefile.
- Added Makefile.ams and configure.ac for autoconf/automake.
Darbkot 7f2: April 05, 2004
- Fixed the google function. Google changed some text that
the bot was using to tell if the search was successful.
Darkbot 7f1: Mar 06th, 2004
- Made a short dirty fix for "!randq *" crashing the bot.
If you do a randq query consisting entirely of * and ?
characters, the bot will now just spit out a random quote.
This needs to be fixed better, obviously, but this will
keep peoples' bots from crashing until the issue can be
properly addressed.
- Changed unlink() calls to remove(). remove() is ANSI C.
- Private message responses no longer have that "sent by"
thing on them. It was annoying, and pointless.
- Renamed the log() function db_log() to avoid a conflict
with a function internal with gcc. Apparently this only
affects newer versions of gcc.
- Removed two unused variables in convertdb.c. I also changed
'unlink' to 'remove', to comply with the ANSI standard.
- Changed forum URL to http://forum.freezedown.org, since that
works too, looks cooler, and is shorter. :)
- Fixed a bug that caused the bot to never respond to anything
after being killed. The same problem was also fixed in a
number of other situations that it was popping up. gs26()
was being called both before, and during prepare_bot(), so
I made the call happen only during prepare_bot().
- Fixed a minor flaw in convertdb.c. It said the syntax was
"convertdb -convert", even if the executable wasn't named
convertdb.
- Taiwanish file got dumped somehow, it's back now.
- New setting in defines.h, AUTOHELP_GUESTS, makes the bot send
a message to the channel, whenever a user with the word "Guest"
in their nickname joins, asking them if they need help. This
can be used in help channels, to avoid Guest users just joining
the channel, and moving on because nobody is talking.
- I'm fairly sure I have dbcron fixed now. I can't test it,
because I don't have a system with crond, but the fix was
made using basic shell syntax. >> instead of >. :)
- Please remember to include which operating system you're using
when reporting bugs. This information is crucial because (all?)
operating systems have subtle differences that can cause any
number of problems in various situations. It's impossible to
keep all of these conditions in mind when writing code, because
there's just so many of them. Any other information that you can
provide will, more than likely, be greatly appreciated.
- I don't see why this is a development version anymore, so
I've moved it to final. As always, any malfunctions or
problems may be reported via the forum.
- darkbot.info isn't resolving anymore, so references to this
site have been removed. I left the support emails, until
updated email addresses are known of. If your email needs
to be updated anywhere in the code, and I didn't realize it,
let me know.
- Changed setup.ini, WHATSNEW, according to previous statement.
- Updated some text in defines.h
- Updated the title screen in main.c
- Removed references of "make cygwin". Just use "make win"
from now on.
- Fixed a typo in the Makefile.
- You can use comments in the performs file now by appending
a '#' to the beginning of the line.
Darkbot 7.0-RC9: Oct 19th, 2003
- Added new channel command, "QUOTE". All this does right
now is display a random line from randomstuff.ini on
command.
Darkbot 7.0-RC9: Oct 5th, 2003
- This feature was already added, but I never documented it...
The R~ variable (random nickname) now works in RDB topic
responses. Look for randomstuff compatibility in the near
future, but first i have to rewrite do_random_stuff() to
accept a channel arguement.
- I was reading through this WHATSNEW file, and corrected
a few typos that were made.
- I removed the run_deop() code. It didn't work very
well anyway, or at all actually. I plan on reintroducing
this whenever I can get some free time.
- Fixed Ebonic language file.
- Added Taiwanish language option.
Darkbot 7.0-RC8: June 20th, 2003
- I screwed up the Makefile by accident, adding some
new features, and I hadn't finished yet when I
committed. OOPS. Fixed now.
- Updated more depricated URL strings.
- Updated language files.
- Minor changes on startup splash screen.
- Support forum URL is now http://www.freezedown.org/forum
- Updated the default servers.ini file to reflect the
changes.
- You can now use Darkbot on servers which require a
connection password. Check servers.ini for an
example.
- Updated some outdated text in the configure script.
- Darkbots now default to irc.freezedown.org #darkbot.
Please edit your setup.ini and servers.ini files to
minimize traffic, since that is also our help channel.
Darkbot 7.0-RC7: June 2nd, 2003
- Updated the INSTALL.txt file to reflect some support
changes.
- Fix for possible problems with counting in datasearch
algorithm. long was changed to size_t.
- Fixed bug that prevented ACTIONs from being used on
RDB responses.
- Suppressed more warnings when compiling on Solaris
from chan.c, in the do_math function.
- Removed another unused variable from url.c
- Removed an unused variable from random.c
- Removed the .runonce script from executing during the
"make" process. The funcionality this script produced
is depricated. Also removed this file from the distro.
- Darkbot will now properly compile on Solaris. To make
this happen, you need to manually edit source/Makefile,
and remove a comment symbol before the word "LIBS".
- Suppressed a warning message from main.h that happened
when compiling on Solaris.
- Makefile now works correctly on Solaris.
- The MEM command is now limited to only users with admin
(level 3) access on the bot.
- On startup, we now run_performs() BEFORE we join our home
channel. This fixes an issue that happened chiefly on
Undernet, and allows the bot to authenticate and set
umode +x, before it joins any channels. I hope to fix
this in a better way, but for now it's driving me nuts.
- The startup screen now actually reflects what version this
is. Sorry, I forgot all about that startup screen, because
it's hard coded. hehe.
- The Q~ variable in topic replies now works correctly. It
was chopping all but the first word off, before.
- Added MrSiMo to the list of contributors for his Arabic
translation.
- The sleep command now accepts an arguement for the number
of seconds you want the bot to sleep for.
- DEFAULT_UMODE is now set immediately upon connection.
Several users said this was not being done, it was. It was
just waiting >300 seconds, for whatever reason. Also, the
bot command PERFORMS now sets DEFAULT_UMODE in addition
to running the performs file.
- New command line option.
-I now specifies the location of the directory containing
the data files (by default, dat/).
- Multiple command line arguements are now supported.
I have no clue why this wasn't done before.
- The .debug and .debug2 scripts were missing from the
distribution. They're back now.
- Found another place where the bot wasn't deleting old
userlist entries. This has been fixed.
- Added the CHANUSERS command. All this does is return
a list of users on either the specified channel, or
the current channel, if none is specified. I may
remove this eventually, as i'm just using it for
debugging purposes right now.
- CHANINFO command will output to whatever channel it
received the command from now, instead of the channel
it's showing data about.
- The CHANINFO command now supports a channel name
parameter. Dunno why it didn't have that before...
- Darkbot is on CVS now at SourceForge!
- Soapta revamped the google module.
- The MEM command now displays the correct process. I removed
the -x flag from the ps command it was issuing, and it fixed
it. If anyone sees any reason the -x flag should be used,
let me know and i'll recode the whole thing.
- Added SETHOST alias for the VHOST command.
- Updates to the Ebonic and French languages which define
Lbadtopic and Lbadtopic2 now. Other languages still need
this added.
- The RDB command, which gives information about the number
of RDB files, can now be used with an arguement, to tell
how many lines are in a specific RDB file. It was supposed
to do this before, but it didn't work properly. This
command is still unavailable in Windows.
- Removed a warning concerning do_randq that happened if you
compiled with RANDOM_STUFF undefined.
- Fixed another bug that was causing the bot to never remove
old entries from it's internal user list. This time it wasn't
parsing the channel name for PARTs correctly. I also removed
some parsing being done on an unused variable whenever
someone parted a channel.
- Fix for RDB command... i forgot to change this when I moved
all of the RDB files to their own directory. OOPS! :)
Darkbot 7.0-RC6: Oct 30th, 2002
- Added Arabic language.
- You can now toggle the use of encrypted userlist.db passwords.
Check defines.h for this.
- Fix for the bot not executing performs when it connects to
a server which does not have an MOTD. Also cleaned up a small
amount of redundant code dealing with performs.
- The bot will no longer crash if it encounters blank lines in
the info2.db during data searches (DSEARCH and SEARCH commands).
Darkbot 7.0-RC5: Sep 24th, 2002
- Fixed do_randomtopic(), so it's now possible to output the first
quote. it never did this before (oops).
- Fixed the socket connection routines for windows.
- Fixed a rather large bug that caused the bot to never actually delete
users from the internal user list when necessary.
This also fixes another problem where the bot would put return a
nickname from R~ that is not actually on the channel.
- RDB topics now support the use of tokenized responses. This includes
the use of tokenized responses in the WHUT and DUNNO replies.
- Added timers directory to the distribution, it was missing.
- Got rid of the do_randomtopic2() function for the random dunno, and
random whut replies. do_randomtopic() now handles everything. This
cut down the size of the code a bit, and should have been how it was
done originally, anyway. This also means variables and also raw
commands can now be used in the replies for whut, and dunno, also.
- Added a level 3 helper command, "PERFORMS", which just executes all
all commands that are in the bot's performs.ini file, at any time.
- Fixed minor oversight that I created when adding a check for illegal
characters in !nick, it now lets you use all legal characters.
- RDB topic responses can now contain raw commands.
- RDB files are now stored in their own directory. By default, this is
dat/rdb.
- Changed get_word() function to make it a little more useful.
- Changed some error replies in the RANDQ function, and added a response
for the condition of randomstuff.ini being empty.
- Cleaned up the prototypes.h file, it looked really ugly. :)
This also reduced the total amount of code by a bit, but i'm not going
to bother checking just how much. :P
- Fixed an issue in seen, that might cause the bot to improperly count
the number of seens in the database.
- Fixed minor bug in add_randstuff() that caused the bot to say there was
one more randomstuff in the file it's adding to than there actually was.
- Fixed a bug in do_random_stuff() that prevented the bot from outputting
randomstuffs, in very rare instances. This suspectedly was causing some
strangeness noted in Debian, and some other OSs.
- Added a new alias for randomstuff, RS.
- Fixed a bug in !USERLIST, that caused the bot to flood itself, and not
show of all of the users it was supposed to show.
!USERLIST now works correctly, and hopefully on ALL OS.
- Fixed a bug in !BANLIST that caused it to not output correctly on some
OS.
- Due to abuse and channel cluttering, the !VARIABLES command now messages
the user with the output, instead of sending it to the current channel.
- Fixed a compilation error concerning BITCH_DEOP_REASON being undeclared.
What i did is remove this, and now if BITCH_ABOUT_DEOP is turned on, it
just runs the list of commands in deop.ini. If BITCH_ABOUT_DEOP is turned
off, it does nothing when the bot is deoped. Apparently, before this
version, it ALWAYS ran deop.ini, and the BITCH_ABOUT_DEOP just toggled the
bot saying whatever line was defined in BITCH_DEOP_REASON. That seemed kind
of pointless, to me, but i never noticed it before now.
Darkbot 7.0-RC4: Jun 24th, 2002
Again, Ron did a couple necessary and urgent changes and fixes:
- Finally, the bug in windows concerning DEL and REPLACE has
been corrected. A function which checks readability and
writeability was leaving the info2.db file open at startup,
and causing all sorts of problems, since the new code structure
was implemented.
- NO NEED FOR TOP LINE WITH NUMBER ANYMORE on random phrase files.
... After yet even more problems with randomstuffs being counted
improperly, I've recoded the entire randomstuff routine.
They no longer rely on any number at the top of the file, which
means you can remove that number from your randomstuff.ini.
Optimizations made to make randomstuff more random, also.
- Fixed a bug where Darkbot would crash when you use !nick
with illegal characters.
- Patched a socket issue in create_connection() that appeared
only in windows.
- Eliminated a warning dealing with the redefinition of size_t
when compiling the bot in windows.
- Eliminated all of the casting done on malloc in the program.
Casting malloc is totally unnecessary, and can mask other
errors.
- Improved the fix for topics that consist entirely of "*"
characters. It now checks for "?" also. This prevents
segmentation faults, and topics which are entirely wild-
cards are seriously annoying anyway. Sorry if it's in any
inconvenience to anyone.
- Minor cosmetic fix to the output of DBSIZE, it'll now say
that the database is "1 byte in size", instead of "1 bytes
in size", if it's only 1 byte. This should never happen,
but if it does, it'll look nice. :)
- Added #define MSG_RESPONSES to defines.h to have Darkbot
answering or not to private queries. Check next 2 defines.
(default is OFF)
- Added #define ALLOW_ADD_IN_MSG to turn ON or OFF the
possibility of ADDing database entries to Darkbot in
private message. (default = OFF)
- Added #define ALLOW_DEL_IN_MSG to turn ON or OFF the
possibility of DELeting database entries from Darkbot in
private message. (default = OFF)
- Added RANDQ function and alias RANDQUOTE, to output a random
line from your randomstuff.ini that contains a specified search
string.
RANDQ output returns a (11/23) type thing at the beginning of
the line, which tells which quote it's showing, out of how many
were matched in your search.
RANDQ can be used from any channel, and in MSG. It wont output
An obvious side effect to this, is that the ~ variable in
randomstuffs will evaluate to a nickname, if it's used in private
message (The nickname of whoever invoked it).
To make the function toggleable a directive with the same name
was made on defines.h (default = ON)
Try it out, !RANDQ <stuff>
- Added RANDQ2 command, which is the same as RANDQ, only it
matches case sensitively.
- Added BACKUP_RANDOMSTUFF define to backup randomstuff.ini
file every time a random phrase is added. This was done due
to missing contents when adding an entry on a file with a high
ammount of phrases. Latest fixes resolves the problem but this
define will stay to play on the safe side and/or if user likes
to backup changed files.
- Added hostmask code, where the bot converts hostmasks to
*jason@*.superlink.net, or *jason@203.203.203.*.
- After lots of complaints, the second line in the info reply
only shows up with the stats command now.
Shell utilities
- Adjusted check-integrity to the non necessity anymore of top
line with number of random entries on random phrases files.
- configure script now forces entering at least one server
and at least one user level 3, on servers.ini and userlist.db
files respectively, in case those files are empty.
(working on checking errors on user input).
- added an option on 'configure' to import servers.ini and
userlist.db from another location.
- Added BSDs compatibility to all shell scripts.
- Added Cygwin compatibility to AddServer, AddUser,
check-integrity and download-databases scripts (live-update
and dbcron not fully tested yet).
Darkbot 7.0-RC3: May 22nd, 2002
ron@freezedown.org has worked on the following 4 issues:
- Fixed a bug that caused crashes if the bot responds to a
topic containing R~ in private message.
- Fixed a bug that caused excess floods if the bot were to
send private messages to itself.
- Fixed a bug concerning topics that consists entirely of the
'*' character, which caused segmentation faults. Darkbot
will not allow you to add a topic like this now.
- Fixed the Makefile, on my computer it kept compiling all
of the source files seperately and then compiling them all
together instead of linking the .o files it made.
- Added directory logs lost in action. It is now within dat directory
- Fixed .Stripdb and .Stripdb2 - so now points to the correct bin path
Shell utilities: (all changed/improved - read docs/README_UTILS)
- Added README_UTILS to docs directory with information about shell utils
- Added compatibility to wget (besides lynx) on scripts that needs to
connect to internet
- All utility scripts now share working directory .scriptutils instead of
having dynamic files all over scripts directory
- download-databases now integrated on live-update (besides standalone)
(if updated on RC3 the change will take effect next time live-update
is executed)
- Added a couple more features and improved others for more accuracy on
check-integrity engine. USE IT before asking for help or going into
paranoia if you suspect you have data errors or even if you are not
sure eventual errors became from bad entries on data files.
- Added a few features to AddUser utility
- configure script now bypasses previously configured items. Just hit
ENTER key to go to the next setup. Also it gets already configured
parameters and use it as session defaults instead of the usual Darkbot
defaults. The script is now linked to AddUser and AddServer with all
features those utilities now have.
Darkbot 7.0-RC2: Apr 13th, 2002
- Windows port. Not much to do at this time. Last changes
on the core code made some commands not working properly.
Any interested coder... the affected commands
are DELETE, which do not delete, and REPLACE, which leaves
in info2.db 2 entries with the same topic. I should remind
all coders that the source must be sent together with it's
executable/bin files. Any coder willing to participate use
the email on top of this info or directly to me
at LuizCB@darkbot.info . (only development matters please)
- The following are a couple Unix scripts to help on Darkbot
management. Most are complete, some needs small adjustments
or more features. I've used basic sh technics on it's making,
I should say, while learning the language on the fly.
Please test them and send any modiffs in case you are able
to. The idea of these shell scripts is mainly to open a door
to C coders to implement them so it will be possible to port
it to other platforms.
- A more featured AddServer. Downloads and installs servers
of the network you choose. Thanks to the folks at the
International Federation of IRC - http://ifirc.com
for a job well done on your site! The merit of that will
go to our web page on the credits area as soon as stable
version 7 is released.
- New crontab setup utility. Run dbcron on scripts dir and
if crontab is active on your shell the script will do
everything for you (10 mins interval cron job).
- Implemented a new update utility. On scripts
directory type ./live-update -h for help on it's
usage. At this stage the update engine will not
transfer your previous directives on defines.h
or darkbot.c to the new file, so you'll have to
edit defines.h manually and compile Darkbot.
The script is compatible with all Darkbot releases
and can be launched standalone providing it's in
scripts directory. To install it ( in case you don't have
it with your Darkbot) type
lynx -source http://live-update.darkbot.info > live-update
then chmod +x live-update
(get-latest will no longer be available)
- New download-databases utility. ( it will be integrated soon on
live-update engine but can also work standalone).
- New file-integrity utility ( still needs some ajustments and
more features but you can use it already - works with
download-databases utility or by itself). Type
./check-integrity to check info2.db. Due to unpredictable
user entries on info2.db this utility could behave
abnormally on some special characters. Please send me all
info2.db file in case anything like that happens so I can
make exclusions on the code.
Changes applied by reet:
- Fixed major bug when adding users - the password wasn't
encrypted, thus user could never login.
- Added new commands IGNORE & UNIGNORE syntax is:
<bot> ignore <nick>
<bot> unignore <nick>
The ignore list is only stored in RAM, changing
nicks will get around this ignore. This is useful
to ignore people who query the bot too much.
- Applied code optimization patches on info and check_permban,
submited by Neil Darlow
- Preview for next full release: adjustments on shell utilities
and a full featured menu GUI might be finished. Minor
changes in meanwhile can be updated using live-update
engine.
Darkbot 7.0-RC1: Mar 2nd, 2002
- Fixed get-latest script; besides checking for code updates
also looks for latest news. Database files updates
will be also done/actualized soon. It's not linked
anywhere by now so if you want to use it type it's
name.
- Organized file structure; all scripts are now on scripts
directory, documents on docs except README which is
now on Darkbot's root dir. A new contributors file
was created with the list of colaborators.
- defines.h is now organized in different way and prepared
to a "shell GUI" to be released soon.
- Organized 'configure' in a different way. Now it starts
with defines.h editing and then it goes to data files.
- scripts/dbcron - a new script to execute crontab. There is
plenty of help how to use in it. Read it. Soon the
reconnection process will me automated.
- Updated makefile to reflect the new directory tree.
- Code contributors please use this release as the base of
your changes.
- The next changes are code modifications also in preparation
for release 7, mostly adapted, updated or implemented
by reet, paul @ darkbot.info
- Added GOOGLE feature. Simply type:
<bot> google <search string>
The bot will then return the first URL google
returns.
#define GOOGLE ON to use this feature.
- ********** IMPORTANT **********************************
- userlist.db passwords are now *ENCRYPTED*
If you are using an older version userlist.db
you MUST set all the passwords to 0 *** OR ***
Cygwin/Windows users run convert.exe
UNIX users run ./convert
and your userlist.db will be converted
*******************************************************
- #define PERFORM_TIMER ON if you want darkbot to send its
PERFORM.INI to the IRC server every 60 seconds, useful
if your bot is banned from a channel, or couldn't
log in to channel services due to a net split etc.
It's in defines.h
Darkbot 7 (alpha 2.1): Dec 23rd, 2001
- Fixed 'INFO2.DB must have at least one topic' problem. Bot
should work normally, even if INFO2.DB is empty.
- Added 'stats' support to darkbot, <botnick> stats will return
total number of questions asked since it started
recording. You can also do <botnick> stats <nickname>
to get indivdual stats from a user. dat/stats.db holds
the data.
- Added 'quiz' support to darkbot, <botnick> quiz to execute
the quiz, it will pick a random question/answer from
dat/quiz.db. The format of the question answer in the
file should be <question>@<answer>
e.g. What is 1+1?@The answer is 2!
quiz is still in experimental stages, check defines.h
to enable/set it up.
Darkbot 7 (alpha 2): Dec 17th, 2001
- New define - #define VOICE_USERS_ON_JOIN [on/off]
- New commands: /msg bot infosize or /msg bot dbsize
or in channel: bot infosize or bot dbsize
returns the file size of INFO2.DB
- New command: bot whisper <nick> about <topic>
darkbot will NOTICE the user, instead of PRIVMSG
- Moved source code and Makefile to source directory -
this keeps the root tree of darkbot clean, nothing
changes for the user, they still type make in the
darkbot root, and the binary will be copied there.
- Repaired get_rand_nick() problem - bot was still returning
it's own nick - *should* be ok now.
- Added Ron's random whut, and dunno function.
Darkbot 7 (alpha 2): Dec 16th, 2001
- Removed #ifdef WIN32 references for sprintf/snprintf,
have included the function snprintf() in general.c,
for older compilers - #define SNPRINTF_SUPPORT should
be switched OFF if your compiler supports snprintf()
this is quite a change.
- Due to lots of people not reading #defines.h and complaining
about make error (clock_t), the configure script
will display an alert about this just before defines.h
is about to be edited.
- New defines - #define CONNECT_WAIT_TIMEOUT [seconds]
#define OP_USERS_ON_LOGIN [on/off]
- New PRIVMSG commands - OP, DEOP, VOICE/V, DEVOICE/DEV/DV/,
DVOICE, KICK/WACK/K, DELETE/REMOVE/
FORGET/DEL, TELL, ADD/REMEMBER/SAVE,
WHERE/WHO, ADDUSER, DIE
Some of them aren't new, but didn't work, and are now fixed.
Just /msg bot tell nick about topic, these commands
usually NOTICE the user, rather than PRIVMSG.
- The connection routine to the server should be better -
instead of quitting after failing to connect, it
will constantly cycle all the servers.
- I've added CYGWIN support in the Makefile - just to hide
those size_t warnings if you get them. If you use
CYGWIN, just use make cygwin
- Permban bug fixed.
- Info/Info2 bug fixed.
- NICK bug fixed - bot will keep the new nick until it quits.
- There is a bug/feature where if a nick has a pipe (|) and
requests a topic that has raw - commands, it ignores
them - looking in to this.
diff --git a/scripts/AddServer b/scripts/AddServer
index 4cc5bc2..52b3d30 100755
--- a/scripts/AddServer
+++ b/scripts/AddServer
@@ -1,477 +1,477 @@
#!/bin/sh
PID=0624233000
PNAS="
* Darkbot Servers Utility *
<***********_~_***********>
"
# changes: dependencies - option of using lynx or wget (041402)
ABORT () {
echo -e "\nThis utility will stop now!\n\nLeav\
ing $0 ...\n\n\n"; sleep 1; exit 0
}
DB_SCRIPTS_PATH () {
cd scripts 2>/dev/null
dirutil="scripts"
filutil="`basename $0`"
# check if dir is correct
if ! echo `pwd` | grep -q "\/"$dirutil""; then
# file is not being launched from $dirutil
if [ -d "$dirutil" ]; then # dir is there
# if file is not in the correct dir
if [ ! "`ls "$dirutil" | grep "$filutil"`" ]; then
# file is not in the correct dir so move it
clear
echo -e "$PNAS\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory.\n"
echo "Moving it now...."
sleep 2
cat > db_wrong_path << EOF[WP]
mv -f $0 "$dirutil"/
cd "$dirutil"/
echo -e "\n| Your "$filutil" is now located in your "$dirutil" directory |
| Launch it from there when necessary |\n\n"
sleep 4
$0
rm -f ../db_wrong_path
exit 0
EOF[WP]
. db_wrong_path
else # file is in dir so just cd
cd "$dirutil"/
fi
else # dir is not there so don't bother - tell user to move it
clear
echo -e "$PNAS\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory and launched from there or Darkbot's root.
Please move it and launch it again."
sleep 3
ABORT
fi
fi
}
#DB_SCRIPTS_PATH
BASE_WORKDIR=.scriptutils
TMP=$BASE_WORKDIR/._tmp/as$$
mkdir -p $BASE_WORKDIR/._tmp/
trap 'rm -fr $BASE_WORKDIR/._tmp* >/dev/null 2>&1' 0
m_trap="echo -e \n\n -- `basename $0` terminated by `whoami` --\n\n"
trap '$m_trap 1>&2; exit' 1 2 3 13 15
FILESERV="../dat/servers.ini"
ABORT () {
echo -e "\nThis utility will stop now!\n\nLeav\
ing $PNAS...\n\n\n"; sleep 1; exit 0
}
SERVERS_HELP () {
echo -e "$PNAS
Basically what this script does is managing your servers.ini file by adding
removing and changing servers and ports.
You have the option of manipulating only your local servers file or downloading
an updated server list from the International Federation of IRC and work with
those servers.
On all lists the servers are preceded by a number (which is not in fact part of
the files) to help you better choose or manage each entry.
On the remote servers list the ports displayed on the right are only for your
reference and corresponds to all available ports. It's recommendable to select
option 2 on the menu to load the external servers before changing local ports
so you'll have updated information to deal with.
If you decide to move all remote list to your local file, port 6667 will be
used for all servers. You can later change that port for each server on the
main menu, option 8.
On all lists PgUp/Down or arrow keys scrolls the text; Q quits from the list.
CTRL+C aborts at all times.
To launch the utility write $0. For a quick server entry write:
$0 server port (ex: $0 irc.server.here 6667 )\n
Comments, suggestions?
-Support: http://forum.freezedown.org\n"
+Support: http://darkbot.sourceforge.net\n"
if [ -n "$insider" ]; then echo "[ Hit ENTER to continue ]"; read PTR; fi
}
# test environment
TESTDEPEND () {
NonFatalError () {
echo "NON FATAL ERROR at $0 (`date`): $FiLe not detected on this system. \
Going to simple operation mode, which means only simple SERVER addition will \
be performed..." >> $BASE_WORKDIR/error_messages
clear
echo -e "$PNAS\nNON FATAL ERROR: $FiLe not detected on this system.
Going to simple operation mode, which means only simple SERVER addition will
be performed...\n"
}
if ! (type "$1" 1>/dev/null 2>&1); then
FiLe="$1"
NonFatalError $1
sleep 1; unset $FiLe
fi
}
TESTDEPEND "grep"; TESTDEPEND "sed"; TESTDEPEND "cut"; TESTDEPEND "cat"
# test dependencies which can have optional programs and set vars for those.
TESTDEPEND_SUBST () {
# test lynx/wget
if (type "lynx" 1>/dev/null 2>&1); then
dld_prg="lynx"
else
if (type "wget" 1>/dev/null 2>&1); then
dld_prg="wget"
fi
fi
if [ -z "$dld_prg" ]; then
echo -e "FATAL ERROR at $0 (`date`): lynx and wget not detected \
on this system. One it's necessary for this utility to work \
properly" >> $BASE_WORKDIR/error_messages
echo -e "$PNAS\nFATAL ERROR at $0 (`date`)\n\n
Either lynx or wget are essential for $0 to work properly.
None of those programs were found on this system"
ABORT
fi
}
TESTDEPEND_SUBST
# dat/servers.ini
DISPLAY_LOCAL () {
if [ ! -e "$FILESERV" ] || [ ! -s "$FILESERV" ]; then
# echo -e "$PNAS\nThere are no servers present."; sleep 2
echo " #### There are no servers present - servers.ini is empty ####"; sleep 2
LASTACTION="Unaccomplished action - no servers present on ../dat/servers.ini."
else
clear
echo -e "$PNAS* Local Server List ** "$FILESERV" ** \n
[ PgUp/Down or arrow keys scrolls; Q quits from the list ]\n
`cat -b "$FILESERV"`\n
" | less -deXF
echo " Press ENTER to continue"; read PTR
LASTACTION="Displayed Darkbot servers list."
fi
}
QUICK_ADD () {
clear
echo ""$ADDserv" "$ADDport"" >> "$FILESERV"
echo -e "$PNAS\nAdded to your "$FILESERV" exactly this entry:
"$ADDserv" "$ADDport"\n\n"
}
ADDSERVER () {
unset SERV; unset PORT
while [ -z "$SERV" ]
do
clear
echo -n "$PNAS
Enter a server name: "
read SERV
if [ -z "$SERV" ]; then
echo -e "You MUST specify a server!\n"
sleep 1
fi
done
while [ -z "$PORT" ]
do
echo -n "
What port to connect to on $SERV? [6667] "
read PORT
if [ -z "$PORT" ]; then
echo -e "\n Defaulting port to 6667...\n"
PORT=6667
sleep 1
fi
done
echo "$SERV $PORT" >> $FILESERV
LASTACTION="Added: SERVER: "$SERV" PORT: "$PORT""
if [ -e "$TMP.TESTDEPEND" ]; then
clear
echo -e "$PNAS\nAdded to your "$FILESERV"\n Server: "$SERV" - Port: "$PORT"\n\n"
fi
}
DELSERVER () {
if [ -s "$FILESERV" ]; then
unset DEL_SERV
echo -n "Please enter the number corresponding to the server to be removed: "
read DEL_SERV
svr_num_lines="$(cat "$FILESERV" | wc -l | tr -cd '[:alnum:]')"
if [ ! -z "$DEL_SERV" ]; then
# if [ "$DEL_SERV" -le "$srv_num_lines" ]; then
REMOVED=$(sed -n $DEL_SERV"p" $FILESERV)
if [ ! -z "$REMOVED" ]; then
sed $DEL_SERV"d" $FILESERV > $TMP.FILESERV
LASTACTION="Removed: $REMOVED."
cat $TMP.FILESERV > $FILESERV
LASTACTION="Removed from your Darkbot IRC servers list: $REMOVED."
else
LASTACTION="Unaccomplished server entry removal - invalid input."
fi
else
LASTACTION="Unaccomplished server removal - no servers present on $FILESERV."
fi
fi
}
CHANGEPORT () {
if [ -s "$FILESERV" ]; then
unset READ_SERV_NUM; unset NEW_PORT
cat -b $FILESERV > $TMP.FILESERV
while [ -z "$READ_SERV_NUM" ]; do
echo -n "Enter the number corresponding to the server to change the port: "
read READ_SERV_NUM
SERV_TMP=$(sed -n $READ_SERV_NUM"p" $FILESERV | cut -d' ' -f1)
OLD_PORT=$(sed -n $READ_SERV_NUM"p" $FILESERV | cut -d' ' -f2)
done
## Possible port choices/ confront with remote server then put var on echo
if [ "$RemoteStatus" != "off" ]; then
PossPortChoices=$(sed -n /$SERV_TMP/p $TMP.NETW_NAME | cut -d: -f2)
fi
clear
while [ -z "$NEW_PORT" ]; do
echo -n "$PNAS
Current port on $SERV_TMP: $OLD_PORT.
`if [ ! -z $PossPortChoices ]; then echo Available ports: $PossPortChoices; fi`
Enter the new port or press ENTER for default [6667]: "
read NEW_PORT
if [ -z $NEW_PORT ]; then NEW_PORT=6667; fi
sed -e '/'$SERV_TMP'/s/'$OLD_PORT'/'$NEW_PORT'/' $FILESERV > $TMP.2.FILESERV
cat $TMP.2.FILESERV > $FILESERV
done
LASTACTION="Changed port $OLD_PORT to $NEW_PORT on $SERV_TMP"
else
LASTACTION="Unaccomplished port change - no servers present on $FILESERV."
fi
}
# remote servers
GET_REMOTE () {
if [ ! -s $TMP.rem.servers ]; then
DLD_PRG_COMMLINE () {
if [ "$dld_prg" = "lynx" ]; then
lynx -source -nostatus http://ifirc.com/servers.ini 2>/dev/null > $TMP.rem.servers
else
wget -qO $TMP.rem.servers http://ifirc.com/servers.ini
fi
}
trymax="3"; trycount="0"
while [ "$trycount" != "$trymax" ] && [ ! -s $TMP.rem.servers ]; do
trycount=`expr $trycount + 1`
echo -e "$PNAS\n An updated server list is being downloaded from the
International Federation of IRC - http://ifirc.com.\n
Please wait...\n"
DLD_PRG_COMMLINE
#cp servers.ini $TMP.rem.servers # debug only
# cp $TMP.rem.servers servers.ini # debug only
done
unset testRemote
-testRemote=$(grep undernet $TMP.rem.servers)
+testRemote=$(grep freenode $TMP.rem.servers)
if [ -z "$testRemote" ]; then
echo -e "$PNAS\n I can't obtain the remote servers list at this time"
LASTACTION="Remote (external) server list unreachable."
RemoteStatus="off"
fi
fi
}
SELECT_REMOTE () {
if [ ! -z "$testRemote" ]; then
while [ ! -s "$TMP.NETW_NAME" ]; do
clear
echo -n "$PNAS
* External Server List *
-Write the name of the IRC network (ex: Undernet): "
+Write the name of the IRC network (ex: Freenode): "
read NETW_NAME
if [ ! -z "$NETW_NAME" ]; then
grep -i "$NETW_NAME": $TMP.rem.servers | cut -d: -f3-4 | sed s/GROUP// > $TMP.NETW_NAME
grep -i "$NETW_NAME": $TMP.rem.servers | cut -d: -f3 | sed 's/$/ 6667/' > $TMP.EXTERNAL_ALL6667
grep -i "$NETW_NAME": $TMP.rem.servers | cut -d: -f3 | sed 's/$//' > $TMP.EXTERNAL_NOPORTS
if [ ! -s $TMP.NETW_NAME ]; then
echo -e "\nERROR: I don't have network '$NETW_NAME' on my list.\n"
sleep 1
fi
fi
done
fi # testRemote != null
}
DISPLAY_REMOTE () {
if [ ! -z "$testRemote" ]; then
if [ ! -s $TMP.NETW_NAME ]; then
SELECT_REMOTE
clear
fi
echo -e "$PNAS* External Server List ** $NETW_NAME ** \n
[ PgUp/Down or arrow keys scrolls; Q quits from the list ]\n
`cat -b $TMP.NETW_NAME`\n
" | less -deXF
echo " Press ENTER to continue"; read PTR
LASTACTION="Displayed remote servers list."
# cat -b $TMP.NETW_NAME > NETW_NAME # debug only
# cat $TMP.NETW_NAME > NETW_NAME # debug only
fi # testRemote != null
}
ADDSERVER_REMOTE () {
unset READ_REM_SERV_NUM
if [ ! -s $TMP.NETW_NAME ]; then SELECT_REMOTE; fi
if [ ! -z "$testRemote" ]; then
ADD_1_REMOTE () {
cat -b $TMP.NETW_NAME | less -deXF
while [ -z "$READ_REM_SERV_NUM" ]; do
echo -n "
Enter the number corresponding to the server to be added: "
read READ_REM_SERV_NUM
REM_SERV_TMP=$(sed -n $READ_REM_SERV_NUM"p" $TMP.EXTERNAL_NOPORTS)
REM_SERV_PORTS=$(sed -n $READ_REM_SERV_NUM"p" $TMP.NETW_NAME | cut -d: -f2)
done
clear
echo -n "$PNAS
Available ports for "$REM_SERV_TMP": "$REM_SERV_PORTS"
Write the port number for "$REM_SERV_TMP"
or press ENTER for default [6667]: "
read READ_REM_SERV_PORT
if [ -z $READ_REM_SERV_PORT ]; then READ_REM_SERV_PORT=6667; fi
echo "$REM_SERV_TMP" "$READ_REM_SERV_PORT" >> $FILESERV
LASTACTION="Added SERVER "$REM_SERV_TMP", PORT "$READ_REM_SERV_PORT"."
}
APPEND_ALL_REMOTE () {
cat $TMP.EXTERNAL_ALL6667 >> "$FILESERV"
LASTACTION="Appended all servers from "$NETW_NAME" to your Darkbot IRC servers!"
}
OVERWRITE_ALL_REMOTE () {
cat $TMP.EXTERNAL_ALL6667 > "$FILESERV"
LASTACTION="Overwrited your Darkbot servers file with all servers from "$NETW_NAME"!"
}
fi # testRemote != null
}
SERVERS_MENU () {
while [ "$CHOICE" != "0" ]; do
unset servini_status_; unset servini_status
if [ ! -e "$FILESERV" ] || [ ! -s "$FILESERV" ]; then
servini_status_="*"
servini_status=" Not available - empty file"
fi
if [ "$RemoteStatus" = "off" ]; then
RemoteStatus1="*" # for menu
fi
clear
if [ -f "$FILESERV" ]; then TOTAL_LOCAL_SERV="$(cat "$FILESERV" | wc -l | tr -cd '[:alnum:]')"; fi
if [ "$TOTAL_LOCAL_SERV" = "1" ]; then server_s="server" ; else server_s="servers" ; fi
if [ "$TOTAL_LOCAL_SERV" = "" ]; then TOTAL_LOCAL_SERV="0" ;fi
echo -e "$PNAS
`if [ ! -z "$LASTACTION" ]; then
echo -e " | Last action/status:\n |" $servini_status_""$RemoteStatus1" "$LASTACTION" "; else echo "MAIN MENU"; fi`
| Number of servers currently in servers.ini file: "$TOTAL_LOCAL_SERV"
[1] Display my `if [ "$TOTAL_LOCAL_SERV" != "0" ]; then echo "$TOTAL_LOCAL_SERV"; fi` "$server_s". "$servini_status_"
[2] Display the external server list. "$RemoteStatus1"
[3] Add a server to my local server file. (manually)
[4] Add a server from the external list. (pick one) "$RemoteStatus1"
[5] Add all servers from the external server list. (append to local) "$RemoteStatus1"
[6] Add all servers from the external server list. (overwrite local) "$RemoteStatus1"
[7] Change the port on a server. "$servini_status_"
[8] Remove a server from my servers file. "$servini_status_"
[9] Remove all servers from my servers.ini file. "$servini_status_"
(C) Check my servers.ini file for errors (fast mode). "$servini_status_"
(H) HELP
(X) EXIT Darkbot Servers Utility.
"$servini_status_" $servini_status \n"
echo -n "Enter your choice: "
read CHOICE
case $CHOICE in
1)
#clear; DISPLAY_LOCAL;;
DISPLAY_LOCAL;;
2)
clear; GET_REMOTE; DISPLAY_REMOTE;;
3)
clear; ADDSERVER;;
4)
clear; GET_REMOTE; ADDSERVER_REMOTE; ADD_1_REMOTE;;
5)
clear; GET_REMOTE; ADDSERVER_REMOTE; APPEND_ALL_REMOTE;;
6)
clear; GET_REMOTE; ADDSERVER_REMOTE; OVERWRITE_ALL_REMOTE;;
7)
#clear; DISPLAY_LOCAL; CHANGEPORT;;
DISPLAY_LOCAL; CHANGEPORT;;
8)
#clear; DISPLAY_LOCAL; DELSERVER;;
DISPLAY_LOCAL; DELSERVER;;
9)
if [ "$servini_status_" != "*" ]; then
cat servers.ini > "$FILESERV" 2>/dev/null
echo "REMOVING all servers from servers.ini...";
LASTACTION="Removed all servers from servers.ini file."
else
echo " #### No servers to remove. File servers.ini is empty ####"
LASTACTION="Unaccomplished servers removal - empty file."
fi
sleep 2;;
C)
if [ "$servini_status_" != "*" ]; then
if [ ! -s check-integrity ]; then
LASTACTION="Unaccomplished file check - utility not installed."
else
./check-integrity servers -quick
LASTACTION="Checked servers.ini for errors."
fi
else
LASTACTION="Unaccomplished file check - empty file."
fi;;
c)
if [ "$servini_status_" != "*" ]; then
if [ ! -s check-integrity ]; then
LASTACTION="Unaccomplished file check - utility not installed."
else
./check-integrity servers -quick
LASTACTION="Checked servers.ini for errors."
fi
else
LASTACTION="Unaccomplished file check - empty file."
fi;;
h)
clear; insider=y; SERVERS_HELP;;
H)
clear; insider=y; SERVERS_HELP;;
x)
exit 0;;
X)
exit 0;;
*)
if [ -z $CHOICE ]; then
echo -e "\nERROR: Playing with the ENTER key..?"; sleep 2; clear
else
echo -e "\nERROR: '$CHOICE' is not a valid choice"; sleep 2; clear
fi
esac
done
}
# start engines
if [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--h" ]; then
clear; SERVERS_HELP
elif [ ! -z "$1" ] && [ ! -z "$2" ]; then
ADDserv="$1"; ADDport="$2"; QUICK_ADD
elif [ ! -e "$TMP.TESTDEPEND" ]; then SERVERS_MENU
else
ADDSERVER
fi
diff --git a/scripts/AddUser b/scripts/AddUser
index 55f0c02..b19b1fc 100755
--- a/scripts/AddUser
+++ b/scripts/AddUser
@@ -1,289 +1,289 @@
#!/bin/sh
PID=0624233000
PNAU="
* Darkbot Users Utility *
<**********_~_**********>
"
# to do: check errors on user input
ABORT () {
echo -e "\nThis utility will stop now!\n\nLeav\
ing $0 ...\n\n\n"; sleep 1; exit 0
}
DB_SCRIPTS_PATH () {
dirutil="scripts"
filutil="`basename $0`"
# check if dir is correct
if ! echo `pwd` | grep -q "\/"$dirutil""; then
# file is not being launched from $dirutil
if [ -d "$dirutil" ]; then # dir is there
# if file is not in the correct dir
if [ ! "`ls "$dirutil" | grep "$filutil"`" ]; then
# file is not in the correct dir so move it
clear
echo -e "$PNAU\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory.\n"
echo "Moving it now...."
sleep 2
cat > db_wrong_path << EOF[WP]
mv -f $0 "$dirutil"/
cd "$dirutil"/
echo -e "\n| Your "$filutil" is now located in your "$dirutil" directory |
| Launch it from there when necessary |\n\n"
sleep 4
$0
rm -f ../db_wrong_path
exit 0
EOF[WP]
. db_wrong_path
else # file is in dir so just cd
cd "$dirutil"/
fi
else # dir is not there so don't bother - tell user to move it
clear
echo -e "$PNAU\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory and launched from there or Darkbot's root.
Please move it and launch it again."
sleep 3
ABORT
fi
fi
}
#DB_SCRIPTS_PATH
BASE_WORKDIR=.scriptutils
TMP=$BASE_WORKDIR/._tmp/au$$
mkdir -p $BASE_WORKDIR/._tmp/
trap 'rm -fr $BASE_WORKDIR/._tmp* >/dev/null 2>&1' 0
m_trap="echo -e \n\n -- `basename $0` terminated by `whoami` --\n\n"
trap '$m_trap 1>&2; exit' 1 2 3 13 15
FILEUSER="../dat/userlist.db"
ABORT () {
echo -e "\nThis utility will stop now!\n\nLeav\
ing $PNAU...\n\n\n"; sleep 1; exit 0
}
USERS_HELP () {
echo -e "$PNAU
This utility displays, adds and removes user entries on your userlist.db file.\n
While displaying file contents all entries are preceded by a number (which is
not in fact part of the files) to help you better choose or manage each user.\n
If the entries goes over screen size use arrow keys or PgUp/Down to scroll and
type Q to quit or scroll the list to it's very end so it will automatically
exit and proceed to the next function. CTRL + C aborts at all times.\n
To launch the utility write $0. For a quick user entry write:
$0 userid@host level Ex: $0 *whateverid@*host.domain.net 2
(It will add an user with access level 2 to all channels).\n
Comments, suggestions?
-Support: http://forum.freezedown.org\n"
+Support: http://darkbot.sourceforge.net\n"
if [ -n "$insider" ]; then echo "[ Hit ENTER to continue ]"; read PTR; fi
}
# test environment
TESTDEPEND () {
NonFatalError () {
echo "NON FATAL ERROR at $0 (`date`): $FiLe not detected on this system. \
Going to simple operation mode, which means only simple USER addition will \
be performed..." >> $BASE_WORKDIR/error_messages
clear
echo -e "$PNAU\nNON FATAL ERROR: $FiLe not detected on this system.
Going to simple operation mode, which means only simple USER addition will
be performed...\n"
}
if ! (type "$1" 1>/dev/null 2>&1); then
FiLe="$1"
NonFatalError $1
sleep 1; unset $FiLe
fi
}
TESTDEPEND "grep"; TESTDEPEND "sed"; TESTDEPEND "cut"; TESTDEPEND "cat"
# dat/userlist.db
DISPLAY_USERDB () {
if [ ! -e "$FILEUSER" ] || [ ! -s "$FILEUSER" ]; then
echo -e "$PNAU\nThere are no user entries present."
LASTACTION="Unaccomplished action: no users entries to display."
else
echo -e "$PNAU* Local User List ** "$FILEUSER" ** \n
| ---- If entries goes over screen's vertical size ---- |
| ---- PgUp/Down or arrow keys scrolls; Q quits from the list ---- |\n
`cat -b "$FILEUSER"`\n
" | less -deXF
echo " Press ENTER to continue"; read PTR
LASTACTION="Displayed Darkbot users list."
fi
}
CHECK_SYNTAX () {
echo $null
}
QUICK_ADD () {
clear
echo "#* "$ADDuser" "$ADDlevel" 0 0" >> "$FILEUSER"
echo "$PNAU
Added to your "$FILEUSER" exactly this entry:
#* "$ADDuser" "$ADDlevel" 0 0\n\n"
}
ADDUSER () {
echo -e "\n$PNAU\n
The format of the user@host must be *userid@*.host.isp
Exs: *jason@*.superlink.net <-- dyanmic ip
*mtr@darkmind.eclipse.net <-- static host
*darkmind@204.127.145.* <-- unresolved host\n"
unset NICK; unset LEVEL
while [ -z "$NICK" ]
do
echo -n "Enter the *user@host of the user you'd like to add: "
read NICK
if [ -z "$NICK" ]; then
echo -e "You MUST specify an user@host!\n"
sleep 1
fi
done
while [ -z "$LEVEL" ]
do
echo "
What level should $NICK be added at?
1) Helper access. Database management commands.
2) Channel operation commands + database management.
3) Bot administrator. All commands.
"
echo -n "Select the level: "
read LEVEL
case $LEVEL in
1)
LEVEL=1;;
2)
LEVEL=2;;
3)
LEVEL=3;;
*)
echo "\"$LEVEL\" is not a valid selection."
sleep 1;;
esac
done
clear
echo -e "\n$PNAU\n
Adding user: $NICK at level $LEVEL..."
echo "#* $NICK $LEVEL 0 0 I need to use SETINFO" >> "$FILEUSER"
echo -e "
Use ADDUSER and DELUSER commands to add or delete users on-line\n
***************************************************************\n
Darkbot now encrypt the password in the userlist!
Be aware if you are logging private messages the encryption
will not cover them, making it possible to see passwords
on the logs. So turn logs off on defines.h if you don't want
that to happen.
All users added with this script will have a password of 0
and should set their new password on IRC by issuing the command
/msg Darkbot pass 0 new_password.\n
***************************************************************\n"
echo -e "Press ENTER to continue."
read PTR
}
DELUSER () {
if [ -s "$FILEUSER" ]; then
echo -n "Please enter the number corresponding to the user entry to \
be removed: "
read DEL_USER
usr_num_lines="$(cat "$FILEUSER" | wc -l | tr -cd '[:alnum:]')"
if [ ! -z "$DEL_USER" ] && [ "$DEL_USER" -le "$usr_num_lines" ]; then
REMOVED=$(sed -n $DEL_USER"p" $FILEUSER)
sed $DEL_USER"d" $FILEUSER > $TMP.FILEUSER
LASTACTION="Removed: $REMOVED."
cat $TMP.FILEUSER > $FILEUSER
LASTACTION="Removed from your Darkbot IRC users list entry:\n "$REMOVED""
else
LASTACTION="Unaccomplished user entry removal - invalid input."
fi
else
LASTACTION="Unaccomplished user entry removal - no users present on $FILEUSER."
fi
}
USERS_MENU () {
while [ "$CHOICE" != "0" ]; do
unset userdb_status_; unset userdb_status
if [ ! -e "$FILEUSER" ] || [ ! -s "$FILEUSER" ]; then
userdb_status_="*"
userdb_status=" Not available - empty file"
fi
#if [ "$RemoteStatus" = "off" ]; then
#RemoteStatus1="*" # for menu
#fi
clear
echo -e "$PNAU
`if [ ! -z "$LASTACTION" ]; then
echo -e " | Last action/status:\n |"$userdb_status_" "$LASTACTION" "; \
else echo "Main Menu"; fi`
[1] Display my userlist.db entries. "$userdb_status_"
[2] Add an user to my userlist.db
[3] Remove an entry from my users file. "$userdb_status_"
[4] Check my userlist.db file for errors (fast mode). "$userdb_status_"
[H] HELP
[X] Exit Darkbot Users Utility.
"$userdb_status_" $userdb_status \n"
echo -n "Enter your choice: "
read CHOICE
case $CHOICE in
1)
clear; DISPLAY_USERDB;;
2)
clear; ADDUSER;;
3)
clear; DISPLAY_USERDB; DELUSER;;
4)
if [ "$userdb_status_" != "*" ]; then
if [ ! -s check-integrity ]; then
LASTACTION="Unaccomplished file check - utility not installed."
else
./check-integrity userlist -quick
fi
else
LASTACTION="Unaccomplished file check - empty file."
fi;;
h)
clear; insider=y; USERS_HELP;;
H)
clear; USERS_HELP;;
x)
exit 0;;
X)
exit 0;;
*)
if [ -z $CHOICE ]; then
echo -e "\nERROR: Playing with the ENTER key..?
Write the number or letter corresponding to the action to take."
sleep 2; clear
else
echo -e "\nERROR: '$CHOICE' is not a valid choice.
Write the number or letter corresponding to the action to take"
sleep 2; clear
fi
esac
done
}
# start engines
if [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--h" ]; then
clear; USERS_HELP
elif [ ! -z "$1" ] && [ ! -z "$2" ]; then
ADDuser="$1"; ADDlevel="$2"; QUICK_ADD
elif [ ! -e "$TMP.TESTDEPEND" ]; then USERS_MENU
else
ADDUSER
fi
diff --git a/scripts/Setup b/scripts/Setup
index 54d51bb..8a83d00 100755
--- a/scripts/Setup
+++ b/scripts/Setup
@@ -1,805 +1,805 @@
#!/bin/sh
PNCFG="
Darkbot Configuration Utility
<************_~_************>
"
PID=0624022000
lparen='('
rparen=')'
# Configures Darkbot
# to do: correcting user entry errors on the fly
ENVIRONMENT () {
BASE_WORKDIR="scripts/.scriptutils"
TMP=$BASE_WORKDIR/._tmp/cfg$$
mkdir -p $BASE_WORKDIR/._tmp/
cfg_vars=$BASE_WORKDIR/.cfg_vars
trap 'rm -fr $BASE_WORKDIR/._tmp* >/dev/null 2>&1' 0
m_trap="echo -e \n\n -- `basename $0` terminated by `whoami` --\n\n"
trap '$m_trap 1>&2; exit' 1 2 3 13 15
# load vars
# utility vars
if [ -e "$cfg_vars" ]; then
. "$cfg_vars"; fi
# setup.ini
if [ -s dat/setup.ini ]; then
cat dat/setup.ini | sed -e s/=/=\"/ -e s/$/\"/ > $TMP-setup.ini
. $TMP-setup.ini
fi
if [ -z "$NICK" ]; then NICK="Darkbot"; fi
if [ -z "$USERID" ]; then USERID="darkbot"; fi
if [ -z "$CHAN" ]; then CHAN="#Darkbot"; fi
if [ -z "$REALNAME" ]; then REALNAME="Get info about me at \
-http://www.freezedown.org "; fi
+http://darkbot.sourceforge.net "; fi
if [ -z "$CMDCHAR" ]; then CMDCHAR="!"; fi
if [ -z "$VHOST" ]; then VHOST="0"; fi
if [ -z "$AUTOTOPIC" ]; then AUTOTOPIC="0"; fi
if [ -z "$SEEN" ]; then SEEN="0"; fi
}
CFG_INTRO () {
clear
echo -e "\n$PNCFG
--------------------------------------------------------------------------"
if [ ! -s "$cfg_vars" ]; then
echo -e "
Welcome to "$cfg_dbrev" configuration, `whoami`.\n
This will lead you through the setup of your Darkbot wich requires your
input during a few minutes.\n
During this process you could change the directives on defines.h file and
edit 3 essential files: setup.ini, servers.ini and userlist.db.
Additionally, perform.ini and deop.ini could also be edited from here.\n
If for any reason after configuring your Darkbot you would like to use
this utility again, previously configured items will be shown as session
defaults."
else
echo -e "
Welcome back to "$cfg_dbrev" configuration, `whoami`.\n"
if [ "$CFG_DEFINES" = "defined" ] && [ "$cfg_dbrev" != "$CFG_LAST_REV" ]; then
echo " Since this is a new Darkbot revision you might want to take a look on \
your
defines.h file again."; fi
echo -e "\n All previously entered information will be used now as session \
defaults.
You can bypass the items you don't want to change by hitting ENTER key.
That data on your \""$NICK"\" will not be modified."
fi
echo -e "\n Where shown, [defaults] can be used by hitting ENTER.
-------------------------------------------------------------------------- \n
[ Hit ENTER to start the configuration, `whoami` ]"
read PTR
}
CFG_VARS () {
# configuration vars
if [ ! -s "$cfg_vars" ]; then
touch $cfg_vars
fi
# CFG_EDITOR
if [ "$1" = "CFG_EDITOR" ]; then
if [ "`grep 'CFG_EDITOR' $cfg_vars`" ]; then
grep -v 'CFG_EDITOR' "$cfg_vars" > $TMP
cat $TMP > $cfg_vars
fi
echo "CFG_EDITOR=\"$CFG_EDITOR\"" >> $cfg_vars
fi
# CFG_DEFINES
if [ "$1" = "CFG_DEFINES" ]; then
if [ "`grep 'CFG_DEFINES' $cfg_vars`" ]; then
grep -v 'CFG_DEFINES' "$cfg_vars" > $TMP
cat $TMP > $cfg_vars
fi
echo "CFG_DEFINES=\"defined\"" >> $cfg_vars
fi
# CFG_LAST_REV
if [ "$1" = "CFG_LAST_REV" ]; then
if [ "`grep 'CFG_LAST_REV' $cfg_vars`" ]; then
grep -v 'CFG_LAST_REV' "$cfg_vars" > $TMP
cat $TMP > $cfg_vars
fi
echo "CFG_LAST_REV=\""$cfg_dbrev"\"" >> $cfg_vars
fi
# CFG_SETUP_INI
if [ "$1" = "CFG_SETUP_INI" ]; then
if [ "`grep 'CFG_SETUP_INI' $cfg_vars`" ]; then
grep -v 'CFG_SETUP_INI' "$cfg_vars" > $TMP
cat $TMP > $cfg_vars
fi
echo "CFG_SETUP_INI=\"set\"" >> $cfg_vars
fi
}
# PROGRAM SETTINGS #
CFG_EDITOR () {
if [ -x "`type -p pico`" ]; then CFG_EDITOR="pico"
else
if [ -x "`type -p emacs`" ]; then CFG_EDITOR="emacs"
else
if [ -x "`type -p vi`" ]; then CFG_EDITOR="vi"
else
if [ -x "`type -p vim`" ]; then CFG_EDITOR="vim"
fi
fi
fi
fi
clear
echo -e "\n$PNCFG\n* choosing text editor *\n
In order to adjust Darkbot to your needs some files might need to
to be chamged so it's necessary to know which text editor to use.\n"
if [ -n "$CFG_EDITOR" ]; then
sleep 2
echo -e " Detected '"$CFG_EDITOR"' installed on your system, but you can \
use other
editor of your choice, providing it is installed and working."
else
# no popular editor detected so have pico as (symbolic) default leaving up to
# the user to decide what to do
sleep 1
echo -e "\n Default one is 'pico' but you can use other editor of your choice,
providing it is present on this system."
CFG_EDITOR="pico"
fi
echo
while [ -z "$EEDITOR" ]
do
sleep 1
echo -n "- Write the name of the text editor you would like to \
use ["$CFG_EDITOR"]: "
read EEDITOR
if [ -z "$EEDITOR" ]; then
echo -e " No editor specified, defaulting to "$CFG_EDITOR". \n"
EEDITOR="$CFG_EDITOR"
fi
done
# put it in var
CFG_EDITOR="$EEDITOR"
CFG_VARS CFG_EDITOR
}
CFG_DEFINES () {
EEDITOR="$CFG_EDITOR"
echo -e "\n Okay, now you will update the directives in defines.h file, changing
the options you want or your system requires by enabling or disabling
it's defines. It is an important file where instructions are given to
create the final executable program.\n
[ Hit ENTER to start editing. ]"
read tmp
# put the file in a TMP for modification comparison
cp -p source/defines.h $TMP.defines.h
$EEDITOR source/defines.h
# if 1 is newer than 2
if [ source/defines.h -nt $TMP.defines.h ]; then
CFG_VARS CFG_DEFINES
CFG_VARS CFG_LAST_REV
# var to instruct new compilation
CFG_DEFINES_CHANGED=y
echo " Changes on defines.h saved!"
else
echo " No changes made on defines.h!"
fi
sleep 3
}
CFG_CMDCHAR () {
while [ -z "$CFG_CMDCHAR" ]
do
clear
echo -e "
$PNCFG
* editing SETUP.ini *
"
echo -n "- Write the command character (CMDCHAR) your Darkbot should respond to
or press ENTER to use pre-defined ["$CMDCHAR"]: "
read CFG_CMDCHAR
if [ -z "$CFG_CMDCHAR" ]; then
CFG_CMDCHAR="$CMDCHAR"
fi
echo -e "
Setting command prefix to '"$CFG_CMDCHAR"'...
To change it online use command "$CFG_CMDCHAR"SETCHAR
"
done
sleep 3
}
CFG_NICK () {
while [ -z "$CFG_NICK" ]
do
clear
echo "
$PNCFG
* editing SETUP.ini *
"
echo -n "- Write the nickname (NICK) you would like to use on your Darkbot
or press ENTER to use pre-defined ["$NICK"]: "
read CFG_NICK
if [ -z "$CFG_NICK" ]; then
CFG_NICK="$NICK"
fi
echo -e "\n Setting nick to '"$CFG_NICK"'...\n
To set it online use the command "$CFG_CMDCHAR"SETNICK \n"
done
sleep 3
}
CFG_USID () {
while [ -z "$CFG_USERID" ]
do
clear
echo "
$PNCFG
* editing SETUP.ini *
"
echo -n "- Write the user id (USERID) you would like to use on "$CFG_NICK"
or press ENTER to use pre-defined ["$USERID"]: "
read CFG_USERID
if [ -z "$CFG_USERID" ]; then
CFG_USERID="$USERID"
fi
echo -e "\n Setting user id to "$CFG_USERID"...\n
To set it online use the command "$CFG_CMDCHAR"SETUSER \n"
done
sleep 3
}
CFG_CHAN () {
while [ -z "$CFG_CHAN" ]
do
clear
echo "
$PNCFG
* editing SETUP.ini *
"
echo -n "- Write the default channel (CHAN) "$CFG_NICK" should use
or press ENTER to use pre-defined ["$CHAN"]: "
read CFG_CHAN
if [ -z "$CFG_CHAN" ]; then
CFG_CHAN="$CHAN"
fi
echo -e "\n Setting default channel to "$CFG_CHAN"...\n
To set it online use the command "$CFG_CMDCHAR"SETCHAN \n"
done
sleep 3
}
CFG_RNAME () {
while [ -z "$CFG_REALNAME" ]
do
clear
echo "
$PNCFG
* editing SETUP.ini *
"
echo -n "- Write the 'real name' (REALNAME) info for "$CFG_NICK"
or press ENTER to use pre-defined one: "
read CFG_REALNAME
if [ -z "$CFG_REALNAME" ]; then
CFG_REALNAME="$REALNAME"
fi
echo -e "\n Setting 'realname' to '"$CFG_REALNAME"'...\n"
done
sleep 3
}
CFG_VHOST () {
while [ -z "$CFG_VHOST" ]
do
clear
echo "
$PNCFG
* editing SETUP.ini *
"
echo -n "- Write the virtual host (VHOST) you want "$CFG_NICK" to use. (0 = no VHOST)
Hit ENTER to use pre-defined one ["$VHOST"]:"
read CFG_VHOST
if [ -z "$CFG_VHOST" ]; then
CFG_VHOST="$VHOST"
fi
echo -e "\n Setting VHOST to "$CFG_VHOST"...\n
To change it online use command "$CFG_CMDCHAR"VHOST \n"
done
sleep 3
}
CFG_WRITE_SETUP_INI () {
clear
echo -e "\n$PNCFG\n* editing SETUP.ini *\n
Writing data settings to setup.ini \n Please wait...\n"
echo "NICK=$CFG_NICK" > dat/setup.ini
echo "USERID=$CFG_USERID" >> dat/setup.ini
echo "CHAN=$CFG_CHAN" >> dat/setup.ini
echo "REALNAME=$CFG_REALNAME" >> dat/setup.ini
echo "CMDCHAR=$CFG_CMDCHAR" >> dat/setup.ini
echo "VHOST=$CFG_VHOST" >> dat/setup.ini
echo "AUTOTOPIC="$AUTOTOPIC"" >> dat/setup.ini
echo "SEEN="$SEEN"" >> dat/setup.ini
sleep 3
CFG_VARS CFG_SETUP_INI
}
CFG_ADDSERVER () {
_CFG_COUNT_SRV () {
srv_num_entries="$(cat dat/servers.ini 2>/dev/null | wc -l \
| tr -cd '[:alnum:]')"
if [ "$srv_num_entries" = "0" ] || [ -z "$srv_num_entries" ]; then
srv_entry_s="You have currently NO server entries in your servers.ini file."
entry_s="entry"
fi
ONLY_1_NET="ATTENTION: Make sure you have servers for ONLY 1 network."
if [ "$srv_num_entries" = "1" ]; then
srv_entry_s="You have currently "$srv_num_entries" server entry \
in your servers.ini. file.\n\n
"$ONLY_1_NET""
entry_s="entry"
fi
if [ "$srv_num_entries" -gt "1" ]; then
srv_entry_s="You have currently "$srv_num_entries" servers entries \
in your servers.ini file.\n\n
"$ONLY_1_NET""
entry_s="entries"
fi
}
_CFG_COUNT_SRV
_CFG_SRV_MENU () {
clear
echo -e "
$PNCFG
* SERVERS.ini *
"$NICK" needs servers addresses to connect to IRC (as many as you want).
"$srv_entry_s"
Select one of the following 4 options:
-1) - Write only one server or use the default [irc.freezedown.org] `if [ ! -z \
+1) - Write only one server or use the default [chat.freenode.net] `if [ ! -z \
"$srv_num_entries" ] && [ "$srv_num_entries" != "0" ]; then \
echo -e "\n ${lparen}This option will overwrite \
the existent "$entry_s" on your servers file${rparen}"; fi`
2) - Use AddServer utility which gives you many options to manage \
your servers
3) - Import a servers.ini file from another location
4) - or hit ENTER to proceed with no changes."
echo -n "
[ Type 1, 2, 3 or press ENTER to proceed ] "
read CHOICE
}
_ADD_1_SERVER () {
while [ -z "$SERVER" ]
do
clear
echo -e "\n$PNCFG\n* SERVERS *\n
-- Enter the server your Darkbot should connect to [irc.freezedown.org]: "
+- Enter the server your Darkbot should connect to [chat.freenode.net]: "
read SERVER
if [ -z "$SERVER" ]; then
-echo -e " No server specified. defaulting to irc.freezedown.org
+echo -e " No server specified. defaulting to chat.freenode.net
You can add servers by running scripts/AddServer
or by editing dat/servers.ini\n"
sleep 2
-SERVER=irc.freezedown.org
+SERVER=chat.freenode.net
PORT=6667
fi
done
while [ -z "$PORT" ]
do
echo -n "- Enter the port to connect to on $SERVER [6667]: "
read PORT
if [ -z "$PORT" ]; then
echo -e " No port specified, defaulting to 6667\n"
sleep 2
PORT=6667
fi
done
if [ ! -z "$SERVER" ] || [ ! -z "$PORT" ]; then
echo -e "\nWriting data settings to servers.ini ....."
sleep 2
echo "$SERVER $PORT (Added: `date`)" > dat/servers.ini
fi
}
# START SRV GROUP FUNCTION
while [ -z "$srv_done" ] || [ "$srv_num_entries" = "0" ] || [ -z "$srv_num_entries" ]; do
_CFG_SRV_MENU
if [ "$CHOICE" = "1" ]; then
unset srv_done
_ADD_1_SERVER
srv_done="y"
_CFG_COUNT_SRV
fi
if [ "$CHOICE" = "2" ]; then
unset srv_done
if [ -s "scripts/AddServer" ]; then
cd scripts
./AddServer
cd ..
else echo "#### ERROR #### UTILITY NOT INSTALLED"; sleep 2
fi
srv_done="y"
_CFG_COUNT_SRV
fi
if [ "$CHOICE" = "3" ]; then
unset srv_done
echo -n "
Write the complete path of servers.ini file to import.
EX: `pwd`/dat/servers.ini : "
read CFG_IMPORT_SRVINI
if [ ! -z "$CFG_IMPORT_SRVINI" ]; then
if [ "`echo "$CFG_IMPORT_SRVINI" | grep 'servers.ini$'`" ]; then
cp -f "$CFG_IMPORT_SRVINI" "`pwd`/dat/servers.ini"
else
echo "#### ERROR #### Invalid servers.ini file!"
fi
sleep 2
else
echo "#### INVALID ENTRY ####"
sleep 2
fi
srv_done="y"
_CFG_COUNT_SRV
fi # end of CHOICE 3
if [ "$CHOICE" = "4" ] || [ "$CHOICE" = "" ]; then
unset srv_done
if [ "$srv_num_entries" != "0" ] && [ ! -z "$srv_num_entries" ]; then
echo -n "
Bypassing servers configuration..."; sleep 1
fi
srv_done="y"
fi
_CFG_COUNT_SRV
if [ "$srv_num_entries" = "0" ] || [ -z "$srv_num_entries" ]; then
echo -n "
## WARNING #########################################################
## You need to have at least one server in your servers.ini file! ##
######################################################################"
sleep 3
fi
done # END OF SRV GROUP FUNCTION
}
CFG_ADDUSER () {
while [ "$usr_num_entries" = "0" ] || [ -z "$usr_num_entries" ]; do
_CFG_COUNT_USR () {
usr_num_entries="$(cat dat/userlist.db 2>/dev/null | wc -l \
| tr -cd '[:alnum:]')"
if [ "$usr_num_entries" != "0" ] || [ -z "$usr_num_entries" ]; then
usr_entry_s="You have currently NO user entries in your userlist.db file."
entry_s="entry"
fi
if [ "$usr_num_entries" = "1" ]; then
usr_entry_s="You have currently "$usr_num_entries" user entry in \
your userlist.db file."
entry_s="entry"
fi
if [ "$usr_num_entries" -gt "1" ]; then
usr_entry_s="You have currently "$usr_num_entries" users entries in \
your userlist.db file."
entry_s="entries"
fi
}
_CFG_COUNT_USR
clear
echo -e "
$PNCFG
* USERLIST.db *
"$NICK" needs at least one user as Darkbot administrator.
"$usr_entry_s"
Select one of the following 4 options:
1) - Add yourself or someone else as administrator `if [ ! -z \
"$usr_num_entries" ] && [ "$usr_num_entries" != "0" ]; then \
echo "\n ${lparen}This option will overwrite \
the existent "$entry_s" on your user list file${rparen}"; fi`
2) - Use AddUser utility with several options to manage "$NICK"'s users
3) - Import a userlist.db file from another location
4) - or hit ENTER to proceed with no changes."
echo -n "
[ Type 1, 2, 3 or press ENTER to proceed ] "
read CHOICE
_ADD_1_USER () {
while [ -z "$ADDUSER" ]
do
clear
echo -e "\n$PNCFG\n* USERS *\n
The format of the user@host is *userid@*.host.isp
Examples:
*jason@*.superlink.net <-- dyanmic ip
*mtr@darkmind.eclipse.net <-- static host
*darkmind@204.127.145.* <-- unresolved host\n
- Enter the *user@host of the administrator you'd like to add: "
read ADDUSER
if [ -z "$ADDUSER" ]; then
echo -e " No *user@host specified. Changing to AddUser utility.\n"
ADDUSER=none
else
echo -e " Writing data to userlist.db ..."
sleep 1
echo "#* $ADDUSER 3 0 0 I need to use SETINFO" > dat/userlist.db
echo -e "
Added to "$NICK"'s userlist.db file as administrator \
(level 3) hostmask:
\"$ADDUSER\". Default password is 0 (zero).
To set your new encrypted password online write:
/msg "$NICK" pass 0 New_Password (then /msg "$NICK" login New_Password)
"
echo -n "[ Hit ENTER to continue ]"
read PTR
fi
done
}
if [ "$CHOICE" = "1" ]; then _ADD_1_USER; _CFG_COUNT_USR; fi
if [ "$CHOICE" = "2" ]; then
if [ -s "scripts/AddUser" ]; then
cd scripts
./AddUser
cd ..
else echo "#### ERROR #### UTILITY NOT INSTALLED;"; sleep 2
fi
_CFG_COUNT_USR
fi
if [ "$CHOICE" = "3" ]; then
echo -n "
Write the complete path of userlist.db file to import.
EX: `pwd`/dat/userlist.db : "
read CFG_IMPORT_USRLST
if [ ! -z "$CFG_IMPORT_USRLST" ]; then
if [ "`echo "$CFG_IMPORT_USRLST" | grep 'userlist.db$'`" ]; then
cp -f "$CFG_IMPORT_USRLST" "`pwd`/dat/userlist.db"
else
echo "#### ERROR #### Invalid userlist.db file!"
fi
sleep 2
else
echo "#### INVALID ENTRY ####"
sleep 2
fi
fi # end of CHOICE 3
if [ "$CHOICE" = "4" ] || [ "$CHOICE" = "" ]; then
_CFG_COUNT_USR
if [ "$usr_num_entries" != "0" ] && [ ! -z "$usr_num_entries" ]; then
echo "
Bypassing user list configuration..."; sleep 1
fi
fi
if [ "$usr_num_entries" = "0" ] || [ -z "$usr_num_entries" ]; then
echo "
## WARNING ###############################################################
## You need to add at least one administrator in your userlist.db file! ##
############################################################################"
sleep 3
fi
done
}
CFG_MENU () {
clear
while [ -z $QUITIT ]
do
echo -e "\n$PNCFG\n* Darkbot configuration menu *\n
1) Setup deop.ini and perform.ini files
2) Read the README files
3) Quit configuration"
echo -n "
Select one: "
read CHOICE
case $CHOICE in
1)
clear
echo -e "
* Darkbot configuration menu *
The .ini's are all in RAW format... so when you
want the bot to MSG your channel \"hello!\", you'd
have to enter something like:
PRIVMSG $CHAN :hello!
(Note the :colon after $CHAN, it is required)
- Check http://www.freezedown.org for examples
+ Check http://darkbot.sourceforge.net for examples
The first .ini you will need to setup, is the perform.ini.
Perform list is a set of commands you'd like your Darkbot
to do when it connects online. This can range from /msging
the channel service login commands (so your Darkbot can
auto get ops), to /joining other channels....
You can later modify this list by editing the perform.ini
[ Hit ENTER to begin editing your perform.ini ]"
read x
$CFG_EDITOR dat/perform.ini
clear
echo -e "\n* Darkbot configuration menu * \n\n
Okay, next is the deop.ini, the format is the same as
perform.ini. What deop.ini is, is a list of commands
you would like your darkbot to do, when it finds itself
deoped in $CHAN. This can range from /msging $CHAN OP ME!
to using other bots/channel services to regain ops.
\n[ Hit ENTER to begin editing your deop.ini ]"
read x
$CFG_EDITOR dat/deop.ini
clear
;;
2)
clear
echo -e "\n$PNCFG\n* reading documents *\n\n
First take a look at the README file...
(use arrow keys to scroll and press Q when you are done)
\n[ Hit ENTER to continue ]"
read PTR
cat README.txt | less -deXF
clear
echo -e "\n$PNCFG\n* reading documents *\n\n
You should take a look also on README_UTILS file...
(use arrow keys to scroll and press Q when you are done)
\n[ Hit ENTER to continue ]"
read PTR
cat docs/README_UTILS | less -deXF
clear
echo -e "\n$PNCFG\n* reading documents *\n\n
Check out what is new in Darkbot!
(use arrow keys to scroll and press Q when you are done)
\n[ Hit ENTER to continue ]"
read PTR
cat docs/WHATSNEW | less -deXF
clear
echo -e "\n$PNCFG\n* reading documents *\n\n
Finally, be aware of who makes this program possible.
(use arrow keys to scroll and press Q when you are done)
\n[ Hit ENTER to continue ]"
read PTR
cat docs/contributors.txt | less -deXF
;;
3)
clear
echo -e "\n$PNCFG * end of configuration *"
if [ ! -e "darkbot" ]; then
echo -e "\nThere is no darkbot binary present.
You'll need to compile the code for Darkbot to run."
else
# if defines.h were changed
if [ -n "$CFG_DEFINES_CHANGED" ]; then
echo -e "\nYour changes made on defines.h file will only take
effect after compiling the code!"
fi
sleep 1
fi
echo "
Darkbot is ready to compile.
If you get any error during compilation process recheck
the changes you made on defines.h reading the comments
next to each directive, starting at 'SYSTEM REQUIREMENTS'.
In case you run into problems, type 'make clean' then 'make
debug' following it's instructions and if Darkbot crashes
type 'backtrace' to find out exactly why it happened.
- If you need further assistance use the support forum at
- http://forum.freezedown.org providing detailed information.
+ If you need further assistance use the support area of
+ http://darkbot.sourceforge.net for detailed information.
Linux/BSD/Unix/Win users type: make
"
sleep 1
QUITIT=yes
;;
*)
echo
if [ "$CHOICE" != 1-3 ]; then echo "That's not a valid selection. \
Select 1 or 2. 3 to quit."; fi
sleep 1
echo
clear
;;
esac
done
}
DB_REV () {
unset cfg_dbrev
cfg_dbrev="$(grep -r obkra sou*/*va*c|rev|tac|cut -d \" -f2|head -n1)"
if [ -z "$cfg_dbrev" ]; then cfg_dbrev=Darkbot; fi
}
START_CFG () {
# if there are no vars means didn't run before so do it all
ENVIRONMENT
DB_REV 2>/dev/null
CFG_INTRO
if [ -z "$CFG_EDITOR" ]; then
CFG_EDITOR
else
clear
echo "
$PNCFG
* Text Editor *
Looks like you have already chosen your default text editor.
Do you want to choose another one instead of '"$CFG_EDITOR"'?
"
echo -n "[ Type Y if you want to select another one or hit ENTER to proceed ] "
read EditorChoice
if [ "$EditorChoice" = "y" ] || [ "$EditorChoice" = "Y" ]; then
CFG_EDITOR
else
echo "
Bypassing editor choice..."; sleep 1
fi
fi
if [ -z "$CFG_DEFINES" ]; then
CFG_DEFINES
else
clear
echo "
$PNCFG
* DEFINES.h *
Do you want to edit your directives on defines.h again?
"
echo -n " [ Type Y if you want to edit defines.h or hit ENTER to proceed ] "
read DefinesChoice
if [ "$DefinesChoice" = "y" ] || [ "$DefinesChoice" = "Y" ]; then
CFG_DEFINES
else
echo "
Bypassing defines.h editing..."; sleep 1
fi
fi
# SETUP.INI -------------------
CFG_SETINI () {
CFG_CMDCHAR; CFG_NICK; CFG_USID; CFG_CHAN; CFG_RNAME; CFG_VHOST
CFG_WRITE_SETUP_INI
}
if [ -z "$CFG_SETUP_INI" ]; then
CFG_SETINI
else
clear
echo "
$PNCFG
* SETUP.ini *
This utility records show you have edited already your setup.ini file.
Do you want to change some settings?
"
echo -n "[ Type Y if you want to edit setup.ini again or hit ENTER to proceed ] "
read SetupChoice
if [ "$SetupChoice" = "y" ] || [ "$SetupChoice" = "Y" ]; then
CFG_SETINI
else
echo "
Bypassing setup.ini configuration..."; sleep 1
fi
fi
CFG_ADDSERVER
CFG_ADDUSER
CFG_MENU
}
START_CFG
exit 0
diff --git a/scripts/check-integrity b/scripts/check-integrity
index 16ef602..899c928 100755
--- a/scripts/check-integrity
+++ b/scripts/check-integrity
@@ -1,2209 +1,2209 @@
#! /bin/sh
PNCI="\nDarkbot Database File Integrity\n<*************_~_*************>\n"
PID=0624233000
SLEEP () { SLEEP=$(sleep $1); }
#cd scripts 2>/dev/null
# to do: function to remove comments from shell utils and c files
# removal of pre-made databases (in conjunction w/download-databases)
# set -x # debug only
USAGE () {
clear
echo -e >&2 "\n$PNCI Checks Darkbot data files for errors.\n
Usage: `basename $0` <file|s|all> [-option|s]
(file triggers are: all; info2; servers; setup; perform; userlist; random)
Options:
-h Shows this brief usage help (read README_UTILS for detailed info)
-quick Speeds up the process bypassing pauses (sleep instances)
-nointro Bypasses introductory information (a)
-report Shows report file contents
-topicsize sets info2.db's topic length (default 50) (a)(b)
-replysize sets info2.db's reply length (default 400) (a)(b)
-default Returns program to it's default values removing all options
(a) The values of these options will be retained unless you use -default
(b) Only necessary if you have a different length then the one on defines.h
WARNING: Darkbot must be offline for most of saved information be effective!
exs:
$0 all Starts utility in full mode
$0 info2 Checks info2.db in normal operation
$0 userlist -quick Checks userlist.db bypassing pauses\n
- Support: http://forum.freezedown.org\n"
+ Support: http://darkbot.sourceforge.net\n"
exit 1
}
ABORT () {
echo -e "\nThis utility will stop now!\n\nLeav\
ing $0 ...\n\n\n"; sleep 1; exit 0
}
DB_SCRIPTS_PATH () {
dirutil="scripts"
filutil="`basename $0`"
# check if dir is correct
if ! echo `pwd` | grep -q "\/"$dirutil""; then
# file is not being launched from $dirutil
if [ -d "$dirutil" ]; then # dir is there
# if file is not in the correct dir
if [ ! "`ls "$dirutil" | grep "$filutil"`" ]; then
# file is not in the correct dir so move it
clear
echo -e "$PNCI\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory.\n"
echo "Moving it now...."
sleep 2
cat > db_wrong_path << EOF[WP]
mv -f $0 "$dirutil"/
cd "$dirutil"/
echo -e "\n| Your "$filutil" is now located in your "$dirutil" directory |
| Launch it from there when necessary |\n\n"
sleep 4
$0
rm -f ../db_wrong_path
exit 0
EOF[WP]
. db_wrong_path
else # file is in dir so just cd
cd "$dirutil"/
fi
else # dir is not there so don't bother - tell user to move it
clear
echo -e "$PNCI\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory and launched from there or Darkbot's root.
Please move it and launch it again."
sleep 3
ABORT
fi
fi
}
ENVIRONMENT () {
cd scripts 2>/dev/null
BASE_WORKDIR=.scriptutils
COMMON_TMP=$BASE_WORKDIR/tmp
mkdir -p $BASE_WORKDIR/tmp
TMP=$BASE_WORKDIR/._tmp/ci$$
mkdir -p $BASE_WORKDIR/._tmp/
ci_vars=$BASE_WORKDIR/.ci_vars
if [ -e "$ci_vars" ]; then
. "$ci_vars"; fi
ci_report=$BASE_WORKDIR/integrity-report
trap 'rm -fr $COMMON_TMP >/dev/null; rm -fr $BASE_WORKDIR/._tmp* >/dev/null 2>&1' 0
m_trap="echo -e \n\n -- `basename $0` terminated by `whoami` --\n\n"
trap '$m_trap 1>&2; exit' 1 2 3 13 15
# SLEEP () { SLEEP=$(sleep $1); }
}
# test environment
TESTDEPEND () {
NonFatalError () {
echo "FATAL ERROR at $0 (`date`): $FiLe not detected \
on this system." >> $BASE_WORKDIR/error_messages
clear
echo -e "$PNCI\nFATAL ERROR at $0 (`date`)\n\n
$FiLe not detected on this system.
It is essential for $0 to work properly."
ABORT
}
if ! (type "$1" 1>/dev/null 2>&1); then
FiLe="$1"
NonFatalError $1
sleep 1; unset $FiLe
fi
}
TESTDEPEND_GO () {
TESTDEPEND "grep"; TESTDEPEND "sed"; TESTDEPEND "cut"; TESTDEPEND "tee"
TESTDEPEND "wc"; TESTDEPEND "tr"; TESTDEPEND "cat"; TESTDEPEND "expr"
}
CI_INTRO () {
count=30; counter=1
while [ $count != "$counter" ]; do
count=`expr "$count" - 1`
clear
echo -e "$PNCI
This information will vanish in ["$count"] seconds...\n
This utility executes a considerable amount of operations during
file integrity verification. It depends on the size of the files
to be checked and errors to correct the time it takes to perform
all it's functions with accuracy.
All process is done without user intervention, so be patient and
wait until it is done or leave it working and check afterwards
it's final results on the integrity-report file or by typing
$0 -report.
If you are in a rush type $0 -quick (fast mode).\n
If you get wrong results on final counts due to unpredictable
characters or symbols you might have on your files please help
-us correct the problem by participating it on the forum.\n
+us correct the problem by participating it on the web page.\n
For detailed information about this utility read README_UTILS.\n
To bypass this introduction write $0 -nointro
To abort all operations at any time press CTRL + C"
SLEEP 1
done
}
LINE_FEED () {
# just for diagnose since DELEMPTY_LINES will fix any eventual problem
clear
echo -e "$PNCI* Line Feed *\n
Checking for missing line feed at the end of file contents...\n"
unset line_feed
if [ "$(tail -n1 $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')" = \
"0" ]; then
echo "- Detected missing Line Feed at the end of $ORIG_FILE!" \
| tee -a $TMP-LINE_FEED.$ORIG_FILE.rep.head
line_feed=y
else
echo "- No missing line feed detected at the end of $ORIG_FILE!" \
| tee -a $TMP-LINE_FEED.$ORIG_FILE.rep.head
fi
SLEEP 4
}
EMPTY_LINES () {
clear
echo -e "$PNCI* Empty Lines *\n
Checking for empty lines on $ORIG_FILE...\n"
SLEEP 1
# check numb lines if not done b4
if [ -z "$numLinesORI" ]; then
numLinesORI=$(cat $ORIG_PATH | wc -l | tr -cd '[:alnum:]')
fi
# added this in case info2.db is empty and the working file is an imported db
if [ ! -z "$numLinesORI" ] || [ "$numLinesORI" != "0" ]; then
numLinesORI=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
fi
# if detected no line feed actual lines will be + 1
if [ "$line_feed" = "y" ]; then
numLinesORI="`expr $numLinesORI + 1`"
CHANGED=""$CHANGED" "$ORIG_FILE""
fi
# clean empty
grep '.' $TMP-DB.WORK.FILE > $TMP-DB.WORK.FILE_TMP
mv -f $TMP-DB.WORK.FILE_TMP $TMP-DB.WORK.FILE
#check numb lines after
numLinesNOW=$(cat "$TMP-DB.WORK.FILE" | wc -l | tr -cd '[:alnum:]')
# REPORT
# a quick report
echo "EMPTY LINES on "$ORIG_FILE"" > $TMP-EMPTY_LINES.$ORIG_FILE.rep.head
if [ "$numLinesORI" != "$numLinesNOW" ]; then
CHANGED=""$CHANGED" "$ORIG_FILE""
numLinesORI_NOW=$(expr $numLinesORI - $numLinesNOW 2>/dev/null)
echo "- Total found - ["$numLinesORI_NOW"] Lines before = "$numLinesORI"\
Lines after = "$numLinesNOW"" | tee -a $TMP-EMPTY_LINES.$ORIG_FILE.rep.head
line_s=$(if [ "$numLinesORI_NOW" -gt "1" ]; then echo lines
else echo line; fi)
echo -e "\nRemoved "$numLinesORI_NOW" empty "$line_s"!"
else
echo "- No empty lines found!" | tee -a $TMP-EMPTY_LINES.$ORIG_FILE.rep.head
fi
SLEEP 4
}
INCOMPL_ENTRIES () {
# checks for lines with only 1 word followed by carriage return
clear
echo -e "$PNCI* Incomplete Entries *\n
Checking for topics with no replies on $ORIG_FILE...\n"
SLEEP 1
grep -ne '^ *[^ ]\+$' $TMP-DB.WORK.FILE > $TMP-noreply
noreply_lines=$(cat $TMP-noreply | wc -l | tr -cd '[:alnum:]')
if [ "$noreply_lines" != "0" ]; then
echo -e " Total found - [$noreply_lines]\n"
# removing it
echo -e "sed '" > $TMP-noreply.to.be.deleted
sed s/:/d' '/ $TMP-noreply | cut -d' ' -f1 >> $TMP-noreply.to.be.deleted
echo -e "' $TMP-DB.WORK.FILE > $TMP-noreply.deleted" >> \
$TMP-noreply.to.be.deleted
echo -e "Removing it...\n"
. $TMP-noreply.to.be.deleted
mv -f $TMP-noreply.deleted $TMP-DB.WORK.FILE
entry_pl=$(if [ "$noreply_lines" -gt "1" ]; then echo entries
else echo entry; fi)
echo -e "Removed "$noreply_lines" incomplete "$entry_pl" from \
$ORIG_FILE!\n"
fi
# REPORT
echo -e "INCOMPLETE ENTRIES (no topic or reply)" > \
$TMP-INCOMPL_ENTRIES.rep.head
if [ -s $TMP-noreply ]; then
echo -e "- Incomplete entries found: "$noreply_lines"" >> \
$TMP-INCOMPL_ENTRIES.rep.head
echo "(Check section \"Removed INCOMPLETE ENTRIES from $ORIG_FILE\" \
on this file)" >> $TMP-INCOMPL_ENTRIES.rep.head
echo -e "===== Removed INCOMPLETE ENTRIES from $ORIG_FILE
`cut -d: -f2- $TMP-noreply`
_______________________ end of incomplete entries \
_______________________" > $TMP-INCOMPL_ENTRIES.rep.body
CHANGED=""$CHANGED" "$ORIG_FILE""
else
echo "- No incomplete entries found!" | tee -a \
$TMP-INCOMPL_ENTRIES.rep.head
fi
SLEEP 4
}
DUP_ENTRIES () {
clear
echo -e "$PNCI* Duplicate Entries *\n
Checking for duplicate entries on $ORIG_FILE ..."
SLEEP 1
# get duplicate lines - 1 item per dups on a vertical list ( for infos)
sort $TMP-DB.WORK.FILE | uniq -di > $TMP.dup.entries
# count number of lines that have repeated replies
dupentries_lines=$(cat $TMP.dup.entries | wc -l | tr -cd '[:alnum:]')
# if there are dup entries proceed with deletion and report
if [ -s $TMP.dup.entries ]; then
# just a condition for entry/entries
if [ "$dupentries_lines" -gt "1" ]; then ENTRY_pl=entries
else ENTRY_pl=entry
fi
echo -e "\n Total found - ["$dupentries_lines"]\n"
# get total num of lines on the main file before entry deletion; used on infos
dupentries_lin_bef=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
#DELETE
# execute uniq - produce final file without repeats
echo -e "Removing it..."
#duplicate "$dupentries_lines" $ENTRY_pl from $ORIG_FILE..."
sort $TMP-DB.WORK.FILE | uniq -i > $TMP-DB.WORK.FILE-TMP
mv -f $TMP-DB.WORK.FILE-TMP $TMP-DB.WORK.FILE
# COUNTS
# count main after
dupentries_lin_aft=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
# result - count amount of repetitions ( lines extracted )
dupentries_lin_rem=$(expr "$dupentries_lin_bef" - "$dupentries_lin_aft")
if [ "$dupentries_lin_rem" -gt "1" ]; then
echo -e "\nRemoved all "$dupentries_lin_rem" repetitions of \
"$dupentries_lines" $ENTRY_pl from $ORIG_FILE!"
else
echo -e "\nRemoved "$dupentries_lin_rem" repetition of \
"$dupentries_lines" $ENTRY_pl from $ORIG_FILE!"
fi
fi
# REPORT
if [ -s $TMP.dup.entries ]; then
echo "DUPLICATE ENTRIES
- Number of entries with repetitions: "$dupentries_lines"
- Number of repetitions found: "$dupentries_lin_rem"
- Number of lines removed: "$dupentries_lin_rem"
(Check section \"Removed DUPLICATE ENTRIES from $ORIG_FILE\" on this file)" \
> $TMP-DUP_ENTRIES.$ORIG_FILE.rep.head
echo -e "===== Removed DUPLICATE ENTRIES from "$ORIG_FILE"" > \
$TMP-DUP_ENTRIES.$ORIG_FILE.rep.body
cat $TMP.dup.entries >> $TMP-DUP_ENTRIES.$ORIG_FILE.rep.body
echo "_______________________ end of duplicate entries \
________________________" >> $TMP-DUP_ENTRIES.$ORIG_FILE.rep.body
CHANGED=""$CHANGED" "$ORIG_FILE""
else
echo
echo "- No repeated entries found!" \
| tee -a $TMP-DUP_ENTRIES.$ORIG_FILE.rep.head
fi
SLEEP 4
}
DUP_TOPICS () {
clear
echo -e "$PNCI* Duplicate Topics *\n
Checking for duplicate topics on $ORIG_FILE ...\n"
SLEEP 1
# get a list of all dups (including repetitions) and line numbers
grep -n . $TMP-DB.WORK.FILE | cut -d' ' -f1 | sed s/:/' '/ | sort +1 | \
uniq -iD -f1 > $TMP.dup.topics
# count number of lines with repeated topics
duptopics_lines=$(cat $TMP.dup.topics | wc -l | tr -cd '[:alnum:]')
# if there are dup topics proceed with deletion and report
if [ -s $TMP.dup.topics ]; then
# get total num of lines on the main file before entry deletion; used on infos
duptopics_lin_bef=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
# get only 1 line of repeats (2nd column on this 1) then sort it/numerical order# this file will have lines not to be removed from main file
# i.e., 1 of the dups needs to be kept on the main file
uniq -id -f1 $TMP.dup.topics | cut -d' ' -f1 | sort -g > $TMP-duptopics.uniques
duptopics_uniques=$(cat $TMP-duptopics.uniques | wc -l | tr -cd '[:alnum:]')
duptopics_repetitions=$(expr "$duptopics_lines" - "$duptopics_uniques")
# condition for topic/topics repetition/s etc
topic_s="$(if [ "$duptopics_uniques" -gt "1" ]; then echo topics; \
dbs_plural=y; else echo topic; dbs_plural=n; fi)"
repetition_s="$(if [ "$duptopics_repetitions" -gt "1" ]; then echo repetitions; \
else echo repetition; fi)"
echo -e " Detected a total of "$duptopics_repetitions" $repetition_s on \
$duptopics_uniques $topic_s!"
if [ "$duptopics_repetitions" -gt 250 ]; then
echo -e "That's a huge amount of repetitions.
This process envolves several operations and can take some time to complete."
fi
echo -e "\n Please wait...\n"
# sort file $TMP.dup.topics so next step will not be a mess
cut -d' ' -f1 $TMP.dup.topics | sort -g > $TMP-duptopics.sorted
entry_ies="$(if [ "$repetition_s" = "repetitions" ]; then echo "entries"; \
else echo "entry"; fi)"
echo -e " Marking "$entry_ies" to be removed...\n"
# compare with diff then extract only lines to be removed from main file
diff -y $TMP-duptopics.sorted $TMP-duptopics.uniques | grep "<" | \
sed s/[[:blank:]]*[\<$]// > $TMP-duptopics.2b.del
# DELETE from main file
# prepare sed operations
echo "sed '" > $TMP-duptopics.2.del
sed 's/$/d/' $TMP-duptopics.2b.del >> $TMP-duptopics.2.del
echo "' $TMP-DB.WORK.FILE > $TMP-topic.lines.deleted" >> $TMP-duptopics.2.del
duplicate_s="$(if [ "$repetition_s" = "repetitions" ]; then echo \
"all "$duptopics_repetitions" duplications"; else echo \
""$duptopics_repetitions" duplication"; fi)"
echo -e " Trying to remove "$duplicate_s" from $ORIG_FILE..."
# execute the file
. $TMP-duptopics.2.del
## move file w/deletes to working file
mv -f $TMP-topic.lines.deleted $TMP-DB.WORK.FILE
# COUNTS
# count main after
duptopics_lin_aft=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
# result - count amount of repetitions ( lines extracted )
duptopics_lin_rem=$(expr "$duptopics_lin_bef" - "$duptopics_lin_aft")
# compare lines on file from total antecipated lines 2 be removed
if [ "$duptopics_lin_rem" = "$duptopics_repetitions" ]; then
if [ "$duptopics_lin_rem" -gt "1" ]; then
echo -e "\nRemoved all "$duptopics_lin_rem" repetitions of \
"$duptopics_uniques" "$topic_s" from $ORIG_FILE!"
else
echo -e "\nRemoved "$duptopics_lin_rem" repetition of \
"$duptopics_uniques" $topic_s from $ORIG_FILE!"
fi
else
echo -e "There is a discrepancy between what was antecipated to be removed
("$duptopics_repetitions $repetition_s") and what whas actually removed \
("$duptopics_lin_rem").
That can be caused by some symbols or characters on your $ORIG_FILE
which are creating a conflict with this utility.
Check $ci_report and compare the results
with what you have in your file."
fi
fi
# REPORT
if [ -s $TMP.dup.topics ]; then
echo -e "\nPlease wait while a copy of all removed entries is being made
and a report generated..."
SLEEP 2
echo "DUPLICATE TOPICS
- Number of topics with repetitions: "$duptopics_uniques"
- Number of repetitions found: "$duptopics_repetitions"
- Number of lines removed: "$duptopics_lin_rem"" > \
$TMP-DUP_TOPICS.rep.head
echo "(You'll find on DUPLICATE TOPICS section of this file all removed entries
in case you would like to modify it and then reinsert it on it's previous
location. One entry with the same topic was left on your $ORIG_FILE file)" \
>> $TMP-DUP_TOPICS.rep.head
if [ "$duptopics_repetitions" != "$duptopics_lin_rem" ]; then
echo -e "##### WARNING #####\nWrong result: Removed \
"$duptopics_lin_rem" of "$duptopics_repetitions" repetitions on \
"$duptopics_uniques" topics.
Check the corresponding section of this file and compare the results with
your $ORIG_FILE file. Data with unpredictable characters might be causing
- the difference. If you discover the cause please contact us at the forum
+ the difference. If you discover the cause please contact us at the official site
and if possible attach the file."
fi >> $TMP-DUP_TOPICS.rep.head
echo -e "===== Removed DUPLICATE TOPICS from "$ORIG_FILE"" > \
$TMP-DUP_TOPICS.rep.body
# prepare sed operations
echo "sed -n '" > $TMP.report_duptopics_0
sed 's/$/p/' $TMP-duptopics.2b.del >> $TMP.report_duptopics_0
echo "' $TMP-DB.WORK.FILE >> $TMP-DUP_TOPICS.rep.body" >> \
$TMP.report_duptopics_0
# execute sed
. $TMP.report_duptopics_0
echo "________________________ end of duplicate topics \
________________________" >> $TMP-DUP_TOPICS.rep.body
CHANGED=""$CHANGED" "$ORIG_FILE""
else
echo "- No duplicate topics found." | tee -a $TMP-DUP_TOPICS.rep.head
fi
SLEEP 5
}
TOPIC_SIZE () {
# checks max length your database topics
# topics + than 400 chars or whatever is set on defines.h's
# define TOPIC_SIZE
clear
echo -e "$PNCI* Maximum Topic Size/Length *\n
Checking maximum character length of the topics entries on $ORIG_FILE...\n"
# if no var with size go for defines.h. if no defimes.h assume 400
if [ ! -n "$TOPIC_SIZE" ]; then
# get defines.h setting if existent
TOPIC_SIZE="$(sed -n '/MAX_TOPIC_SIZE/s/#define[[:blank:]]MAX_TOPIC_SIZE//p' \
../source/defines.h 2>/dev/null | tr -cd '[:alnum:]')"
if [ ! -n "$TOPIC_SIZE" ]; then
echo -e "Unable to obtain configured maximum topic lenght allowed.
Assuming default value of 400 characters...\n
If this is not the setting you actually have please press CTRL + C to abort
and write $0 -topic_size to set the default for this utility.\n"
TOPIC_SIZE=50
SLEEP 2
else
echo -e "Your defined maximum topic length is "$TOPIC_SIZE" characters."
fi
fi
# get max topic length on file
ACTUAL_TOPIC_SIZE=$(cat $TMP-DB.WORK.FILE | cut -d' ' -f1 | wc -L \
| tr -cd '[:alnum:]')
# size+1 - ( if TOPIC_SIZE this will put it as 401
# because what we need is remove all exceeding max length, i.e, 401&+)
TOPIC_SIZE_PLUS_1=`expr $TOPIC_SIZE + 1`
# if length in file is greater than max size... work on it
if [ "$ACTUAL_TOPIC_SIZE" -gt "$TOPIC_SIZE" ]; then
echo -e "- Currently your longest topic (length) is: \
"$ACTUAL_TOPIC_SIZE" characters \n"
SLEEP 1
echo -e "Please wait while the total number of topics exceeding maximum
character lenght allowed is being obtained..."
SLEEP 1
# get all over length
cat $TMP-DB.WORK.FILE | grep -nE '^.[^ ]{'$TOPIC_SIZE',}' \
> $TMP-topic.size.all
if [ -s $TMP-topic.size.all ]; then # we have entries in fault
# get only line numbers ( will be needed to report file )
cut -d: -f1 $TMP-topic.size.all > $TMP-topic.size.all.numb
# get number of lines on working file (later will be used to check if
# operations went right
NUM_LINES_B4=$(cat "$TMP-DB.WORK.FILE" | wc -l | tr -cd '[:alnum:]')
# count total before deletion
NUM_TOPICS_EXCEEDING_SIZE=$(cat "$TMP-topic.size.all.numb" | wc -l \
| tr -cd '[:alnum:]')
echo -e "- Total entries with topic length exceeding size found: \
"$NUM_TOPICS_EXCEEDING_SIZE"\n"
SLEEP 2
echo "Preparing for deletion process..."
SLEEP 1
echo "sed '
`cat $TMP-topic.size.all | sed s/:/d' '/ | cut -d' ' -f1`
' $TMP-DB.WORK.FILE > $TMP-topic.size.deleted" >> $TMP-topic.size.lines.to.del
echo -e "Removing it ..."
SLEEP 1
# execute
. $TMP-topic.size.lines.to.del
# move it to working file
mv -f $TMP-topic.size.deleted $TMP-DB.WORK.FILE
entry_pl=$(if [ "$NUM_TOPICS_EXCEEDING_SIZE" -gt "1" ]; \
then echo entries; else echo entry; fi)
echo -e "Removed "$NUM_TOPICS_EXCEEDING_SIZE" "$entry_pl" from \
"$ORIG_FILE"!\n"
fi # end of -s $TMP-topic.size.all
else # "$ACTUAL_TOPIC_SIZE" is not greater than "$TOPIC_SIZE"
echo -e "\nYour topic's length is within your current configuration
value, which is "$TOPIC_SIZE" characters maximum.\n\n"
SLEEP 3
fi
# REPORT
if [ -s $TMP-topic.size.all ]; then
# first check from the working file
NUM_LINES_AFTER=$(cat "$TMP-DB.WORK.FILE" | wc -l | tr -cd '[:alnum:]')
NUM_LINES_NOW="$(expr "$NUM_LINES_B4" - "$NUM_LINES_AFTER")"
NUM_LINES_DIFF="$(expr "$NUM_TOPICS_EXCEEDING_SIZE" - "$NUM_LINES_NOW")"
# report head top
echo "TOPICS LENGTH" > $TMP-TOPIC_SIZE.rep.head
if [ "$NUM_LINES_NOW" != "0" ]; then # means at least some were removed
# check if are the same as the ones that were supposed too
if [ "$NUM_LINES_NOW" = "$NUM_TOPICS_EXCEEDING_SIZE" ]; then # looks ok
# report header
echo "- Allowed length = "$TOPIC_SIZE" \
Maximum lenght detected = "$ACTUAL_TOPIC_SIZE"
- Entries exceeding configured value = "$NUM_TOPICS_EXCEEDING_SIZE"
- Total entries removed = "$NUM_LINES_NOW""
# report body
echo -e "\n===== Removed TOPICS LENGTH exceeding allowed value on \
"$ORIG_FILE"
`cat $TMP-topic.size.all | cut -d: -f2-`
________________ end of topics with maximum length exceeded \
__________________" > $TMP-TOPIC_SIZE.rep.body
else # something wrong, diff of lines on working file don't match total 2b del
echo "$NUM_LINES_DIFF entries were not removed! Please check report file."
fi
else # final lines count on working file is = 0 so no lines were removed
echo "Something went wrong... not possible to remove entries.
Check report file."
fi
CHANGED=""$CHANGED" "$ORIG_FILE""
else # (-s $TMP-topic.size.all) no entries in fault
echo -e "No topics exceeding maximum length allowd found!"
fi >> $TMP-TOPIC_SIZE.rep.head
SLEEP 5
}
DATA_SIZE () {
# checks max length your database replies
# replies + than 400 chars or whatever is set on defines.h's
# define DATA_SIZE
clear
echo -e "$PNCI* Maximum Reply Size/Length *\n
Checking maximum character length of the replies entries on $ORIG_FILE...\n"
# if no var with size go for defines.h. if no defimes.h assume 400
if [ ! -n "$DATA_SIZE" ]; then
# get defines.h setting
DATA_SIZE="$(sed -n '/MAX_DATA_SIZE/s/#define[[:blank:]]MAX_DATA_SIZE//p' \
../source/defines.h 2>/dev/null | tr -cd '[:alnum:]')"
if [ ! -n "$DATA_SIZE" ]; then
echo -e "Unable to obtain configured maximum reply lenght allowed.
Assuming default value of 400 characters...\n
If this is not the setting you actually have please press CTRL + C to abort
and write $0 -data_size to set the default for this utility.\n"
DATA_SIZE=400
SLEEP 2
else
echo -e "Your defined maximum reply length is "$DATA_SIZE" characters."
fi
fi
# get max reply length on file
ACTUAL_DATA_SIZE=$(cat $TMP-DB.WORK.FILE | cut -d' ' -f2- | wc -L \
| tr -cd '[:alnum:]')
# size+1 - ( if DATA_SIZE this will put it as 401
# because what we need is remove all exceeding max length, i.e, 401&+)
DATA_SIZE_PLUS_1=`expr $DATA_SIZE + 1`
# if length in file is greater than max size... work on it
if [ "$ACTUAL_DATA_SIZE" -gt "$DATA_SIZE" ]; then
echo -e "---- Currently your longest reply (length) is: \
"$ACTUAL_DATA_SIZE" characters ----\n"
SLEEP 1
echo -e "Please wait while the total number of topics exceeding maximum
character lenght allowed is being obtained..."
SLEEP 1
# get length after 1st whitespace//assuming there's no whitspace in front
# cat $TMP-DB.WORK.FILE | grep -En '^[^ ]* +(.{400,})$'
cat $TMP-DB.WORK.FILE | grep -En '^ *[^ ]* +.{'$DATA_SIZE_PLUS_1',}$' \
> $TMP-data.size.all
if [ -s $TMP-data.size.all ]; then # we have entries in fault
# get only line numbers ( will be needed to report file )
cut -d: -f1 $TMP-data.size.all > $TMP-data.size.all.numb
# get number of lines on working file (later will be used to check if
# operations went right
NUM_LINES_B4=$(cat "$TMP-DB.WORK.FILE" | wc -l | tr -cd '[:alnum:]')
# count total before deletion
NUM_REPLIES_EXCEEDING_SIZE=$(cat "$TMP-data.size.all.numb" | wc -l \
| tr -cd '[:alnum:]')
echo -e "- Total entries with reply length exceeding size found: \
"$NUM_REPLIES_EXCEEDING_SIZE"\n"
SLEEP 2
echo "Preparing for deletion process..."
SLEEP 1
echo "sed '
`cat $TMP-data.size.all | sed s/:/d' '/ | cut -d' ' -f1`
' $TMP-DB.WORK.FILE > $TMP-data.size.deleted" >> $TMP-data.size.lines.to.del
echo -e "Removing it ..."
SLEEP 1
# execute
. $TMP-data.size.lines.to.del
# move it to working file
mv -f $TMP-data.size.deleted $TMP-DB.WORK.FILE
entry_pl=$(if [ "$NUM_REPLIES_EXCEEDING_SIZE" -gt "1" ]; \
then echo entries; else echo entry; fi)
echo -e "Removed "$NUM_REPLIES_EXCEEDING_SIZE" "$entry_pl" from \
"$ORIG_FILE"!\n"
fi # end of -s $TMP-data.size.all
else # "$ACTUAL_DATA_SIZE" is not greater than "$DATA_SIZE"
echo -e "\nYour replies length is within your current configuration
value, which is "$DATA_SIZE" characters maximum.\n\n"
SLEEP 3
fi
# REPORT
if [ -s $TMP-data.size.all ]; then
# first check from the working file
NUM_LINES_AFTER=$(cat "$TMP-DB.WORK.FILE" | wc -l | tr -cd '[:alnum:]')
NUM_LINES_NOW="$(expr "$NUM_LINES_B4" - "$NUM_LINES_AFTER")"
NUM_LINES_DIFF="$(expr "$NUM_REPLIES_EXCEEDING_SIZE" - "$NUM_LINES_NOW")"
# report head top
echo "REPLIES LENGTH" > $TMP-DATA_SIZE.rep.head
if [ "$NUM_LINES_NOW" != "0" ]; then # means at least some were removed
# check if are the same as the ones that were supposed too
if [ "$NUM_LINES_NOW" = "$NUM_REPLIES_EXCEEDING_SIZE" ]; then # looks ok
# report header
echo "- Allowed length = "$DATA_SIZE" \
Maximum lenght detected = "$ACTUAL_DATA_SIZE"
- Entries exceeding configured value = "$NUM_REPLIES_EXCEEDING_SIZE"
- Total entries removed = "$NUM_LINES_NOW""
# report body
echo -e "\n===== Removed REPLIES LENGTH exceeding allowed value on \
"$ORIG_FILE"
`cat $TMP-data.size.all | cut -d: -f2-`
________________ end of replies with maximum length exceeded \
__________________" > $TMP-DATA_SIZE.rep.body
else # something wrong, diff of lines on working file don't match total 2b del
echo "$NUM_LINES_DIFF entries were not removed! Please check report file."
fi
else # final lines count on working file is = 0 so no lines were removed
echo "Something went wrong... not possible to remove entries.
Check report file."
fi
CHANGED=""$CHANGED" "$ORIG_FILE""
else # (-s $TMP-data.size.all) no entries in fault
echo -e "No replies exceeding maximum length allowd found!"
fi >> $TMP-DATA_SIZE.rep.head
SLEEP 5
}
# check for entries without related rdb files
CHECK_RDBS () {
clear
echo -e "$PNCI* RDB links and files *\n
Checking for RDB entries on $ORIG_FILE ...\n"
SLEEP 1
# extract possible rdbs links
sed -n /[[:space:]]~[[:alnum:]]/p "$TMP-DB.WORK.FILE" > $TMP-rdb.lines.all
if [ -s $TMP-rdb.lines.all ]; then
# count total
rdb_lines_all=$(cat $TMP-rdb.lines.all | wc -l | tr -cd '[:alnum:]')
# examine which ones are really rdb links and extract uniques
count="0"
while [ $count != "$rdb_lines_all" ]; do
count=`expr $count + 1`
# just a progress ind.
clear; echo -e "$PNCI* RDB links and files *\n
Examining existent RDB links on your $ORIG_FILE...\n"
if [ $count != "$rdb_lines_all" ]; then
echo -e " [`expr $count \* 100 / $rdb_lines_all`%] done\n"
fi
# extract line by line (all lines even ones that are not rdbs)
rdb_line="$(sed -n "$count"p $TMP-rdb.lines.all)"
# if = 2 words -> is a rdb
if [ "`echo "$rdb_line" | wc -w | tr -cd '[:alnum:]'`" = "2" ]; then
# put it on a list
echo "$rdb_line" >> $TMP-rdb.lines.with.repeats
fi
done
SLEEP 3
fi # end of if there are entries with leading ~
# if there are indeed rdb links (count uniques, repeats and extract only links)
if [ -s $TMP-rdb.lines.with.repeats ]; then
# count total (with) repeats
rdb_lines_with_repeats=$(cat $TMP-rdb.lines.with.repeats | wc -l \
| tr -cd '[:alnum:]')
entry_s=$(if [ "$rdb_lines_with_repeats" -gt "1" ]; then echo entries
else echo entry; fi)
echo -e " So far detected "$rdb_lines_with_repeats" "$entry_s" \
with RDB links..."
SLEEP 1
# extract only links; sort; uniq
cat $TMP-rdb.lines.with.repeats | cut -d ' ' -f2 | sort | uniq > \
$TMP-rdb.lines.uniques
# count total uniques
rdb_lines_uniques=$(cat $TMP-rdb.lines.uniques | wc -l | tr -cd '[:alnum:]')
link_s=$(if [ "$rdb_lines_uniques" -gt "1" ]; then echo links
else echo link; fi)
echo -e " Detected "$rdb_lines_with_repeats" "$entry_s" with \
"$rdb_lines_uniques" unique RDB "$link_s"!"
SLEEP 1
fi
# check which rdb files exist on ../dat/
ls ../dat/*.rdb > $TMP-rdb.files.all
# remove whut and dunno, not needed for first operation
grep -vw whut.rdb $TMP-rdb.files.all > $TMP-rdb.files.tmp
grep -vw dunno.rdb $TMP-rdb.files.tmp > $TMP-rdb.files
# count total rdb files for info (before matching)
if [ -s $TMP-rdb.files ]; then
rdb_files_b4=$(cat $TMP-rdb.files | wc -l | tr -cd '[:alnum:]')
file_s=$(if [ "$rdb_files_b4" -gt "1" ]; then echo files; else echo file; fi)
echo -e " Found "$rdb_files_b4" RDB "$file_s" on ..dat/ directory!"
SLEEP 3
# check which links don't have a file
if [ ! -z "$rdb_lines_uniques" ]; then
count="0"
while [ $count != "$rdb_lines_uniques" ]; do
count=`expr $count + 1`
# extract line by line
rdb_line="$(sed -n "$count"p $TMP-rdb.lines.uniques)"
# just a progress ind.
clear; echo -e "$PNCI* RDB links and files *\n
Comparing RDB links from your $ORIG_FILE with \
existent RDB files.\n"
echo " Processing RDB link: $rdb_line ..."
if [ $count != "$rdb_lines_uniques" ]; then
echo -e " [`expr $count \* 100 / $rdb_lines_uniques`%] done\n"
else
echo -e " Done!\n"; fi
# extract rdb link with no leading ~
rdb_link="`echo "$rdb_line" | cut -d' ' -f2 | cut -d~ -f2`"
# compare with the rdb files
# # # test this one better # # #
if [ `grep -w $rdb_link $TMP-rdb.files` ]; then
# means there is a corresponding file
# remove that file from files list so the ones left need to be
# checked because might not have any entry on info2
grep -wv $rdb_link $TMP-rdb.files > $TMP-rdb.files.tmp
mv -f $TMP-rdb.files.tmp $TMP-rdb.files
else
# there is no match; put the line on a file for deletion and report
# first all corresponding link lines with respective number
grep -nw "[[:space:]]*$rdb_line" "$TMP-DB.WORK.FILE" 2>/dev/null >> \
$TMP-rdb.nomatch.all
# then only that link
echo "$rdb_line" >> $TMP-rdb.nomatch.unique
fi
done
SLEEP 3
fi # if [ ! -z "$rdb_lines_uniques" ]; then
fi # if [ -s $TMP-rdb.files ]; then
# count total files without match (the ones left out)
if [ -s "$TMP-rdb.files" ]; then
rdb_files=$(cat $TMP-rdb.files | wc -l | tr -cd '[:alnum:]')
echo -e " Found "$rdb_files" RDB files without any match.\n"
SLEEP 2
fi
if [ -s $TMP-rdb.nomatch.unique ]; then
# count total unique link lines (without repeats) without match
rdb_nomatch_unique=$(cat $TMP-rdb.nomatch.unique | wc -l | tr -cd '[:alnum:]')
echo " Found "$rdb_nomatch_unique" unmatched unique RDB links."
SLEEP 1
# count total links lines (with repeats) without match
rdb_nomatch_all=$(cat $TMP-rdb.nomatch.all | wc -l | tr -cd '[:alnum:]')
echo " (A total of "$rdb_nomatch_all" related entries on $ORIG_FILE)"
SLEEP 1
# prepare a file for deletion and report process
cut -d: -f1 $TMP-rdb.nomatch.all > $TMP-rdb.nomatch.all.linenumb
# extract line/s to be deleted to a tmp file for report
# sed operations
echo "sed -n '" > $TMP-rdb.nomatch.all.2.report
sed 's/$/p/' $TMP-rdb.nomatch.all.linenumb >> $TMP-rdb.nomatch.all.2.report
echo "' "$TMP-DB.WORK.FILE" >> $TMP-CHECK_RDBS.rep.body.0" >> $TMP-rdb.nomatch.all.2.report
# execute sed
. $TMP-rdb.nomatch.all.2.report
# DELETE
echo -e "\nRemoving broken RDB links...\n"
SLEEP 3
# make file with line numbers for deletion
echo "sed '" > $TMP-rdb.nomatch.all.2.del
sed 's/$/d/' $TMP-rdb.nomatch.all.linenumb >> $TMP-rdb.nomatch.all.2.del
echo "' "$TMP-DB.WORK.FILE" > $TMP-rdb.nomatch.all.deleted" \
>> $TMP-rdb.nomatch.all.2.del
# execute it
. $TMP-rdb.nomatch.all.2.del
# move file w/deletes to working file
mv -f $TMP-rdb.nomatch.all.deleted $TMP-DB.WORK.FILE
link_s=$(if [ "$rdb_nomatch_unique" -gt "1" ]; then echo links
else echo link; fi)
echo -e "Removed "$rdb_nomatch_unique" unmatched RDB "$link_s" from \
$ORIG_FILE!"
SLEEP 3
fi # if there were no non matching rdbs
# end of main engine
# REPORT
clear
echo -e "$PNCI* RDB links and files *\n"
SLEEP 1
# report header links
RDBS_rep_head () {
echo "RDB LINKS AND FILES" | tee -a $TMP-CHECK_RDBS.rep.head
if [ ! -z "$rdb_lines_uniques" ]; then
echo "- Existent RDB unique links = $rdb_lines_uniques"
echo "- Existent RDB entries = $rdb_lines_with_repeats"
if [ ! -z "$rdb_nomatch_unique" ]; then
echo "- Total broken unique RDB links = $rdb_nomatch_unique"
echo "- Total entries with broken RDB links = $rdb_nomatch_all"
# make report body for broken links
echo -e "===== Removed BROKEN RDB LINKS from "$ORIG_FILE"" > \
$TMP-CHECK_RDBS.rep.body
cat $TMP-CHECK_RDBS.rep.body.0 >> $TMP-CHECK_RDBS.rep.body
echo "________________________ end of broken rdb links \
________________________" >> $TMP-CHECK_RDBS.rep.body
CHANGED=""$CHANGED" "$ORIG_FILE""
else
echo "- No broken RDB links found!"
fi
else
echo "- Existent RDB links = none found"
fi
# report header files
if [ ! -z "$rdb_files_b4" ]; then
echo "- Existent RDB files = $rdb_files_b4"
if [ ! -z "$rdb_files" ]; then
echo "- RDB files without any RDB lynk = $rdb_files (not removed)"
# make report body for files without rdb links
echo -e "\n===== RDB FILES WITHOUT MATCHING LINKS on $ORIG_FILE
----< NOT REMOVED from ../dat/ directory - do it yourself >----" >> \
$TMP-CHECK_RDBS.rep.body
cat $TMP-rdb.files >> $TMP-CHECK_RDBS.rep.body
echo "________________ end of rdb files without matching links \
__________________" >> $TMP-CHECK_RDBS.rep.body
CHANGED=""$CHANGED" "$ORIG_FILE""
fi
else
echo "- Existent RDB files = none found"
fi
}
RDBS_rep_head | tee $TMP-CHECK_RDBS.rep.head
if [ ! -z "$rdb_nomatch_unique" ]; then
echo "(Check section \"Removed BROKEN RDB LINKS from "$ORIG_FILE"\" \
on this file)" >> $TMP-CHECK_RDBS.rep.head
fi
SLEEP 5
}
RANDOM_FILES () {
clear
echo -e "$PNCI* Random Phrases Files *\n\n
Preparing files for checking.\n
Please wait..."
_RM_RD_TOP_LINE () {
# function to make a var when Darkbot version is affected on the new format
# of random files where top line number is not needed anymore.
# Using backup_randomstuff as a search pattern since it was created on the
# same revision, RC4, instead of more complicate version extraction.
if [ "`grep 'BACKUP_RANDOMSTUFF' ../docs/WHATSNEW 2>/dev/null`" ] \
|| [ "`grep 'BACKUP_RANDOMSTUFF' ../source/defines.h 2>/dev/null`" ]; then
rm_rd_top_line="y"
fi
}
# this condition is here in case i'll decide to trigger this all process from
# (also) another utility, like live-update or configure, so revision will
# be analyzed there
if [ -z "$rm_rd_top_line" ]; then
_RM_RD_TOP_LINE
fi
# make a list of rdb files on dat directory
ls ../dat/*.rdb > $TMP-rd.files.all
# put random.ini and randomstuff.ini on the list of files to check
echo "../dat/random.ini" >> $TMP-rd.files.all
echo "../dat/randomstuff.ini" >> $TMP-rd.files.all
# count total number of lines on the list file
rd_files_all=$(cat $TMP-rd.files.all | wc -l | tr -cd '[:alnum:]')
SLEEP 2
# start checking
count="0"
while [ $count != "$rd_files_all" ]; do
count=`expr $count + 1`
# extract line by line
rd_file="$(sed -n "$count"p $TMP-rd.files.all)"
rd_file_name="$(echo "$rd_file" | cut -d/ -f3)"
# just a progress ind.
clear
echo -e "$PNCI* Random Phrases Files *\n
`expr "$rd_files_all" - "$count"` of "$rd_files_all" files to check. $(if \
[ $count != "$rd_files_all" ]; \
then echo " [`expr $count \* 100 / $rd_files_all`%] done."; \
else echo " Done!"; fi)"
echo -e "Processing "$rd_file_name"\n"
echo -e "Checking for missing line feed at the end of file contents ..."
SLEEP 1
# remove tmp errors file for a new cycle
rm -f $TMP-random.errors.rep.head
# prepare random.ini
if [ "$rd_file_name" = "random.ini" ]; then
grep -wv "^\/\*" ../dat/random.ini > $TMP-random.ini
grep -w "^\/\*" ../dat/random.ini > $TMP-random.ini.comments
rd_file="$TMP-random.ini"
fi
# check numb lines before
rd_numLinesORI=$(cat $rd_file | wc -l | tr -cd '[:alnum:]')
echo " Initial number of lines = "$rd_numLinesORI""
unset line_feed
if [ "$(tail -n1 $rd_file | wc -l | tr -cd '[:alnum:]')" = \
"0" ]; then
echo "- Detected missing Line Feed on the last line!" \
| tee -a $TMP-random.errors.rep.head
line_feed="y"
else
echo "- No missing line feed detected on the last line!"
fi
SLEEP 2
# if detected no line feed actual lines will be + 1
if [ "$line_feed" = "y" ]; then
rd_numLinesORI="`expr $rd_numLinesORI + 1`"
fi
# clean empty lines
echo -e "\nChecking for empty lines ..."
SLEEP 1
grep '.' $rd_file > $TMP-rd_file
# check numb lines after
rd_numLinesNOW=$(cat $TMP-rd_file | wc -l | tr -cd '[:alnum:]')
echo " Number of lines after checking = "$rd_numLinesNOW""
line_s=`if [ "$rd_numLinesNOW" -gt "1" ]; then echo lines; else echo line; fi`
# a quick report
if [ "$rd_numLinesORI" != "$rd_numLinesNOW" ]; then
rd_numLinesORI_NOW=$(expr "$rd_numLinesORI" - "$rd_numLinesNOW" 2>/dev/null)
echo " ### ERROR ###"
echo " Total lines before = "$rd_numLinesORI""
echo " Total lines after = "$rd_numLinesNOW""
echo "- Removed "$rd_numLinesORI_NOW" empty "$line_s"." \
| tee -a $TMP-random.errors.rep.head
echo
else
echo -e "- No empty lines found!\n"
fi
if [ "$line_feed" = "y" ]; then echo " (there is now an additional line \
due to the missing line feed)"; fi #| tee -a $TMP-random.errors.rep.head
SLEEP 1
echo "Checking top line number and random entries..."
SLEEP 1
# check number on top
top_rd_line= total_rd_lines=
top_rd_line=$(head -n1 "$TMP-rd_file" | grep ^[0-9])
total_rd_lines=$(cat "$TMP-rd_file" | wc -l | tr -cd '[:alnum:]')
if [ -n "$top_rd_line" ]; then # there is a number
# if the file being checked is not the only one not in need to remove the line
# on top with the number, which is random.ini, and Darkbot version being checked
# is not prior to the one where top line number is not needed anymore...
if [ "$rd_file_name" = "random.ini" ] || [ $rm_rd_top_line != "y" ]; then
# proceed, it's not included on the files to remove top line
# count lines - subtract 1 from total so top line is not counted
echo " Existent top line number = "$top_rd_line""
rd_lines=$(expr "$total_rd_lines" - 1 2>/dev/null)
echo " Total number of random entries = "$rd_lines""
if [ "$top_rd_line" != "$rd_lines" ]; then # is not the same so it's wrong
echo -e " ### ERROR ### Total line number is not correct!\n Fixing it..."
echo "$rd_lines" > $TMP-fixed.rd.lines
sed 1d "$TMP-rd_file" >> $TMP-fixed.rd.lines
mv -f $TMP-fixed.rd.lines "$TMP-rd_file"
echo "- Replaced top number of random entries from "$top_rd_line" \
to "$rd_lines"" | tee -a $TMP-random.errors.rep.head
else
echo -e "- Random number correct!\n"
fi
else # if $rd_file_name isnot "random.ini" & $rm_rd_top_line is y
# remove top line, it's not needed it on RC4 & +
sed 1d "$TMP-rd_file" >> $TMP-fixed.rd.lines
mv -f $TMP-fixed.rd.lines "$TMP-rd_file"
echo "- Removed top line with number of random entries, not \
needed anymore." | tee -a $TMP-random.errors.rep.head
fi
else # there is no line number on top so make a new file fixed
if [ "$rd_file_name" = "random.ini" ] || [ $rm_rd_top_line != "y" ]; then
# proceed, it's not included on the files to remove top line
echo " Total number of random entries = "$total_rd_lines""
echo -e " ### ERROR ### There is no total lines number on top!
Fixing it..."
echo "$total_rd_lines" > $TMP-fixed.rd.lines
cat "$TMP-rd_file" >> $TMP-fixed.rd.lines
mv -f $TMP-fixed.rd.lines "$TMP-rd_file"
echo "- Added missing total number of random entries of "$total_rd_lines"" \
| tee -a $TMP-random.errors.rep.head
else echo "- Nothing wrong with it. It's not present and it's not needed anymore."
fi
fi
# prep file for report with random file name and errors
if [ -s $TMP-random.errors.rep.head ]; then
echo " Random file "$rd_file_name"" >> $TMP-random.errors.rep.head0
cat $TMP-random.errors.rep.head >> $TMP-random.errors.rep.head0
# prep a file for backup and save
# replace random.ini comments
if [ "$rd_file_name" = "random.ini" ]; then
cat $TMP-rd_file >> $TMP-random.ini.comments
mv -f $TMP-random.ini.comments $TMP-$rd_file_name
else
mv -f $TMP-rd_file $TMP-$rd_file_name
fi
# backup file
echo "echo -e \"\nBacking up "$rd_file_name" before applying the changes...\"
cp -f $rd_file $rd_file.bak
echo \"Moving "$rd_file_name"'s working file to it's original location...\"
mv -f $TMP-$rd_file_name ../dat/$rd_file_name
SLEEP 1" >> $TMP-RANDOM_FILES
fi
echo -e "\nDone with "$rd_file_name"."
SLEEP 3
done
file_s="`if [ "$rd_files_all" -gt "1" ]; then echo files; else echo file; fi`"
# REPORT
# report header
echo "RANDOM PHRASES FILES CHECK
- line feed, empty lines and total entries number -
(only files with errors will be mentioned here)
Total files checked: $rd_files_all" > $TMP-RANDOM_FILES.rep.head
if [ -s $TMP-random.errors.rep.head0 ]; then
cat $TMP-random.errors.rep.head0 >> $TMP-RANDOM_FILES.rep.head
CHANGED=""$CHANGED" "$ORIG_FILE""
else
echo " No errors found on "$rd_files_all" "$file_s" checked!" \
| tee -a $TMP-RANDOM_FILES.rep.head
fi
SLEEP 4
}
SETUP_INI () {
clear
echo -e "$PNCI* setup.ini file *\n"
echo -e "\n - setup.ini file as is before been checked -"
cat $TMP-DB.WORK.FILE
SLEEP 3
echo -e "\nChecking contents of setup.ini file...\n"
SLEEP 1
# count words
numLinesSETUP=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
# count words
numWordsSETUP=$(cat $TMP-DB.WORK.FILE | wc -w | tr -cd '[:alnum:]')
# start checking values
if [ ! "`grep 'NICK=' $TMP-DB.WORK.FILE | cut -d= -f2`" ]; then
echo "NICK=Darkbot"
Missing_Parm="$Missing_Parm""NICK "
else
grep 'NICK' $TMP-DB.WORK.FILE | tr -d ' '
fi > $TMP-DB.WORK.FILE.tmp
if [ ! "`grep 'USERID=' $TMP-DB.WORK.FILE | cut -d= -f2`" ]; then
echo "USERID=darkbot"
Missing_Parm="$Missing_Parm""USERID "
else
grep 'USERID' $TMP-DB.WORK.FILE | tr -d ' '
fi >> $TMP-DB.WORK.FILE.tmp
if [ ! "`grep 'CHAN=' $TMP-DB.WORK.FILE | cut -d= -f2`" ]; then
echo "CHAN=#darkbot"
Missing_Parm="$Missing_Parm""CHAN "
else
grep 'CHAN' $TMP-DB.WORK.FILE | tr -d ' ' > $TMP-DB.WORK.FILE.chan
# check if there isn't a # before channel name
if [ ! `grep 'CHAN=#' $TMP-DB.WORK.FILE.chan` ]; then
sed 's/CHAN=/CHAN=#/' $TMP-DB.WORK.FILE.chan > $TMP-DB.WORK.FILE.chan2
mv -f $TMP-DB.WORK.FILE.chan2 $TMP-DB.WORK.FILE.chan
fi
# check if there isn't a # before channel name after a ,
if [ `grep ',' $TMP-DB.WORK.FILE.chan` ]; then
sed -e 's/,/,#/g' -e 's/##/#/g' $TMP-DB.WORK.FILE.chan > $TMP-DB.WORK.FILE.chan2
mv -f $TMP-DB.WORK.FILE.chan2 $TMP-DB.WORK.FILE.chan
fi
cat $TMP-DB.WORK.FILE.chan >> $TMP-DB.WORK.FILE.tmp
fi >> $TMP-DB.WORK.FILE.tmp
if [ ! "`grep 'REALNAME=' $TMP-DB.WORK.FILE | cut -d= -f2`" ]; then
-echo "REALNAME=Download me from http://www.freezedown.org"
+echo "REALNAME=Download me from http://darkbot.sourceforge.net"
Missing_Parm="$Missing_Parm""REALNAME "
else
grep 'REALNAME' $TMP-DB.WORK.FILE
fi >> $TMP-DB.WORK.FILE.tmp
if [ ! "`grep 'VHOST=' $TMP-DB.WORK.FILE | cut -d= -f2`" ]; then
echo "VHOST=0"
Missing_Parm="$Missing_Parm""VHOST "
else
grep 'VHOST' $TMP-DB.WORK.FILE | tr -d ' '
fi >> $TMP-DB.WORK.FILE.tmp
if [ ! "`grep 'CMDCHAR=' $TMP-DB.WORK.FILE | cut -d= -f2`" ]; then
echo "CMDCHAR=!"
Missing_Parm="$Missing_Parm""CMDCHAR "
else
grep 'CMDCHAR' $TMP-DB.WORK.FILE | tr -d ' '
fi >> $TMP-DB.WORK.FILE.tmp
if [ "`grep 'SEEN' $TMP-DB.WORK.FILE`" ]; then
SEEN=$(grep 'SEEN' $TMP-DB.WORK.FILE | tr -d ' '| cut -d= -f2)
# check if is 0 or 1
if [ "$SEEN" -lt "2" 2>/dev/null ]; then
echo "SEEN="$SEEN""
else
# is not 0 or 1 so check if is off or on
if [ `echo "$SEEN" | grep -i "on" 2>/dev/null` ]; then
echo "SEEN=1"
else
echo "SEEN=0"
fi
fi
fi >> $TMP-DB.WORK.FILE.tmp
mv -f $TMP-DB.WORK.FILE.tmp $TMP-DB.WORK.FILE
clear
echo -e "$PNCI* setup.ini file *\n"
echo -e "\n - setup.ini file as is after being checked -"
cat $TMP-DB.WORK.FILE
echo -e "\n"
echo " - Summary -"
echo "setup.ini file contents" > $TMP-SETUP_INI.rep.head
numLinesSETUP_now=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
if [ "$numLinesSETUP_now" -lt "$numLinesSETUP" ]; then
numLinesSETUP_diff="$(expr "$numLinesSETUP" - "$numLinesSETUP_now")"
fi
numWordsSETUP_now=$(cat $TMP-DB.WORK.FILE | wc -w | tr -cd '[:alnum:]')
if [ "$numWordsSETUP_now" -lt "$numWordsSETUP" ]; then
numWordsSETUP_diff="$(expr "$numWordsSETUP" - "$numWordsSETUP_now")"
space_s=$(if [ "$numWordsSETUP_diff" -gt "1" ]; then echo spaces;
else echo space; fi)
echo "- Found "$numWordsSETUP_diff" misplaced empty "$space_s"!"
else echo "- No misplaced spaces found!"
fi | tee -a $TMP-SETUP_INI.rep.head
if [ -n "$Missing_Parm" ]; then
echo "- Missing values on `echo "$Missing_Parm" | \
sed s/[[:space:]]/,' '/` (defaults were used)"
else
echo "- Parameters and values looks ok."
fi | tee -a $TMP-SETUP_INI.rep.head
echo
if [ -n "$numLinesSETUP_diff" ] || [ -n "$numWordsSETUP_diff" ] || \
[ -n "$Missing_Parm" ]; then
echo "setup.ini contents and syntax appears to be correct now." \
| tee -a $TMP-SETUP_INI.rep.head
echo -e "\n===== setup.ini file contents before changes
`cat $ORIG_PATH`
________________ end of setup.ini file before changes made \
__________________" > $TMP-SETUP_INI.rep.body
CHANGED=""$CHANGED" "$ORIG_FILE""
else
echo "setup.ini contents and syntax appears to be correct." \
| tee -a $TMP-SETUP_INI.rep.head
fi
echo
SLEEP 5
}
SERVERS_INI () {
clear
echo -e "$PNCI* servers.ini file *\n"
echo -e " - servers.ini file as is before been checked -"
cat $TMP-DB.WORK.FILE
SLEEP 1
# count lines
numLinesSERVERS=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
# count words
numWordsSERVERS=$(cat $TMP-DB.WORK.FILE | wc -w | tr -cd '[:alnum:]')
count="0"
numMissPORTS=0
while [ $count != "$numLinesSERVERS" ]; do
count=`expr $count + 1`
servers_tmp="$(sed -n "$count"p $TMP-DB.WORK.FILE)"
if [ `echo "$servers_tmp" | grep -E :` ]; then
server="$(echo $servers_tmp | cut -d: -f1)"
port="$(echo $servers_tmp | cut -d: -f2 | grep [0-9])"
else
server="$(echo $servers_tmp | cut -d' ' -f1)"
port="$(echo $servers_tmp | cut -d' ' -f2 | grep [0-9])"
fi
clear
echo -e "$PNCI* servers.ini file *\n
Checking entries syntax...\n
SERVER - "$server"
PORT - "$port""
if [ ! -n "$port" ]; then
echo -e "#### ERROR #####\nNo port detected.\nDefaulting to 6667..."; SLEEP 1
Missing_PORTS=`expr $numMissPORTS + 1`
echo "$server" "6667" >> $TMP-DB.WORK.FILE.tmp
else
echo "$servers_tmp" >> $TMP-DB.WORK.FILE.tmp
fi
SLEEP 1
done
SLEEP 1
clear
echo -e "$PNCI* servers.ini file *\n\n"
if [ -s $TMP-DB.WORK.FILE.tmp ]; then
mv -f $TMP-DB.WORK.FILE.tmp $TMP-DB.WORK.FILE
fi
echo "servers.ini file contents" > $TMP-SERVERS_INI.rep.head
numLinesSERVERS_now=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
if [ "$numLinesSERVERS_now" -lt "$numLinesSERVERS" ]; then
numLinesSERVERS_diff="$(expr "$numLinesSERVERS" - "$numLinesSERVERS_now")"
fi
numWordsSERVERS_now=$(cat $TMP-DB.WORK.FILE | wc -w | tr -cd '[:alnum:]')
if [ "$numWordsSERVERS_now" -lt "$numWordsSERVERS" ]; then
numWordsSERVERS_diff="$(expr "$numWordsSERVERS" - "$numWordsSERVERS_now")"
space_s=$(if [ "$numWordsSERVERS_diff" -gt "1" ]; then echo spaces;
else echo space; fi)
echo "- Found "$numWordsSERVERS_diff" misplaced empty "$space_s"!"
else echo "- No misplaced spaces found!"
fi | tee -a $TMP-SERVERS_INI.rep.head
port_s="$(if [ -n "$Missing_PORTS" ] && [ "$Missing_PORTS" -gt "1" ]; then echo "s"; else echo ""; fi)"
if [ -n "$Missing_PORTS" ]; then
echo "- Missing value$port_s on "$Missing_PORTS" port$port_s! \
(default 6667 were used)"
else
echo "- Apparently there are no errors on entries syntax and PORTS placement."
fi | tee -a $TMP-SERVERS_INI.rep.head
echo
if [ -n "$numLinesSERVERS_diff" ] || [ -n "$numWordsSERVERS_diff" ] || \
[ -n "$Missing_PORTS" ]; then
echo "servers.ini contents and syntax appears to be correct now."
echo -e "\n===== servers.ini file contents before changes
`cat $ORIG_PATH`
________________ end of servers.ini file before changes made \
__________________" > $TMP-SERVERS_INI.rep.body
CHANGED=""$CHANGED" "$ORIG_FILE""
else
echo "servers.ini contents and syntax appears to be correct." \
| tee -a $TMP-SERVERS_INI.rep.head
fi
echo
SLEEP 5
}
USERLIST_DB () {
# just a basic check at this stage
# to do: check repeated IPs at the end of the process besides repeated
# entries at start; optimize all integers check
clear
echo -e "$PNCI* userlist.db file *\n"
# count lines
numLinesUSERLIST=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
usrlst_removed="0"; usrlst_errors="0"; usrlst_errors_b4="0"
count=0
while [ "$count" != "$numLinesUSERLIST" ]; do
count=`expr "$count" + 1`
# get complete line
usrlst_entry="$(sed -n "$count"p $TMP-DB.WORK.FILE)"
clear
echo -e "$PNCI* userlist.db file *\n"
echo -e "[`expr "$numLinesUSERLIST" - "$count"`] entries to be checked.\n"
echo -e "Verifying syntax on entry:\n$usrlst_entry\n"
# get complete line
#usrlst_entry="$(sed -n "$count"p $TMP-DB.WORK.FILE)"
# if no @ bypass to later remove entry
if [ "`echo "$usrlst_entry" | cut -d' ' -f2 | grep '@'`" ]; then
# check if 1st field or after a , starts with # ( #channel or #*)
usrlst_chan="$(echo "$usrlst_entry" | cut -d' ' -f1)"
usrlst_chan0="$(echo "$usrlst_chan" | sed -e s/,/,'#'/g -e s/'##'/'#'/g)"
if [ ! "`echo "$usrlst_chan0" | grep -E '^\#'`" ]; then
usrlst_chan0="#"$usrlst_chan0""
fi
if [ "$usrlst_chan" != "$usrlst_chan0" ]; then
echo -e "#### ERROR ####\n Channel field incorrect! \
Missing channel prefix '#'. Adding it...\n"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
usrlst_chan="$usrlst_chan0"
fi
# get user mask
usrlst_mask="$(echo "$usrlst_entry" | cut -d' ' -f2)"
if [ "`echo "$usrlst_mask" | grep '\.$'`" ]; then
echo -e "#### ERROR ####\n Unexpected end of user IP! Adding '*'...\n"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
usrlst_mask="$(echo ""$usrlst_mask"*")"
fi
if [ "`echo "$usrlst_mask" | grep -E '\.\.'`" ]; then
echo -e "#### ERROR ####\n Incorrect syntax on user IP '..'. Fixing it...\n"
usrlst_mask="$(echo "$usrlst_mask" | sed 's/\.\./\./')"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
fi
usrlst_ip="@$(echo "$usrlst_mask" | cut -d@ -f2)"
#check if 2nd string starts with * (*userid) not ~ | not *!
usrlst_userid="$(echo "$usrlst_entry" | cut -d' ' -f2 | cut -d@ -f1)"
if [ "`echo "$usrlst_userid" | grep '~'`" ]; then
echo -e "#### ERROR ####\n USER ID field incorrect! Unnecessary leading ~\n"
usrlst_userid="$(echo "$usrlst_userid" | sed 's/~//')"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
fi
if [ "`echo "$usrlst_userid" | grep -E '^\*!'`" ]; then
echo -e "#### ERROR ####\n USER ID field incorrect! Disallowed leading characters *!\n"
usrlst_userid="$(echo "$usrlst_userid" | sed 's/\*\!//')"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
fi
if [ ! "`echo "$usrlst_userid" | grep '^\*'`" ]; then
echo -e "#### ERROR ####\n USER ID field incorrect! Missing leading *\n"
usrlst_userid="$(echo "*"$usrlst_userid"")"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
fi
# check if 3rd colum is 1 2 or 3 (levels)
usrlst_level="$(echo "$usrlst_entry" | cut -d' ' -f3)"
if [ ! "`echo "$usrlst_level" | grep '^[0-3]$'`" ]; then
echo -e "#### ERROR ####\n USER Access level field incorrect! Using 1...\n"
usrlst_level="1"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
fi
# check if 4th column is an integer (times bot saw user)
usrlst_seen="$(echo "$usrlst_entry" | cut -d' ' -f4)"
unset testinteger
testinteger="$(expr "$usrlst_seen" - "0" 2>/dev/null)"
if [ -z "$testinteger" ]; then
echo -e "#### ERROR ####\n Number of times seen field is not an integer! \
Fixing it...\n"
usrlst_seen="0"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
fi
# check if 5th column is password
usrlst_pass="$(echo "$usrlst_entry" | cut -d' ' -f5)"
if [ -z "$usrlst_pass" ]; then
echo -e "#### ERROR ####\n Missing password field! Using password 0...\n"
usrlst_pass="0"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
fi
# check if 6th column is 0 or setinfo
usrlst_setinfo="$(echo "$usrlst_entry" | cut -d' ' -f6-)"
if [ -z "$usrlst_setinfo" ]; then
echo -e "#### ERROR ####\n Missing SETINFO field! Using 0...\n"
usrlst_setinfo="0"
usrlst_errors="$(expr "$usrlst_errors" + 1)"
fi
usrlst_new=""$usrlst_chan" "$usrlst_userid""$usrlst_ip" "$usrlst_level" \
"$usrlst_seen" "$usrlst_pass" "$usrlst_setinfo""
echo "$usrlst_new" >> $TMP-USERLIST.DB
if [ "$usrlst_errors" -gt "$usrlst_errors_b4" ]; then
echo -e "Corrected entry:"
echo "----" >> $TMP-USERLIST_DB.rep.body0
echo "$usrlst_entry" >> $TMP-USERLIST_DB.rep.body0
echo "$usrlst_new" | tee -a $TMP-USERLIST_DB.rep.body0
SLEEP 4
fi
else # no @ on IP
echo -e "#### ERROR ####\n Unable to obtain IP. Entry is being removed...\n"
echo "$usrlst_entry" >> $TMP-USERLIST_DB.rep.body1
usrlst_removed="$(expr "$usrlst_removed" + 1)"
SLEEP 4
fi
usrlst_errors_b4="$usrlst_errors"
done
usrlst_uniq_errors="$(expr "`cat $TMP-USERLIST_DB.rep.body0 2>/dev/null | wc -l | tr -cd '[:alnum:]'`" / 3)"
# if no $TMP-USERLIST.DB means all entries were irrecoverable/wrong / missing @
if [ ! -s $TMP-USERLIST.DB ]; then
touch $TMP-USERLIST.DB
no_entries=y # since file is 0 just a var to avoid 2nd round of dup check
fi
mv -f $TMP-USERLIST.DB $TMP-DB.WORK.FILE
# REPORT
# start gathering results
# get/accumulate results from 1st passage of DUP_ENTRIES
if [ -s $TMP.dup.entries ]; then
dupentries_lines_1="$dupentries_lines"
dupentries_lin_rem_1="$dupentries_lin_rem"
cat $TMP.dup.entries >> $TMP.dup.entries_1
fi
# checking dup entries again if/after changes
if [ -z "$no_entries" ]; then
if [ "$usrlst_uniq_errors" -gt "0" ] || [ "$usrlst_removed" -gt "0" ]; then
clear
echo -e "$PNCI* userlist.db file *\n
Doing a quick check for duplicate entries again on "$ORIG_FILE" after
syntax changes made"
SLEEP 2
DUP_ENTRIES
fi
fi
# get total entries after changes
numLinesUSERLIST_after=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
error_s="$(if [ "$usrlst_errors" -gt "1" ]; then echo errors; else echo error; fi)"
entry_s="$(if [ "$usrlst_uniq_errors" -gt "1" ]; then echo entries; else echo entry; fi)"
clear
echo -e "$PNCI* userlist.db file *\n"
echo "userlist.db file contents" > $TMP-USERLIST_DB.rep.head
echo "- Total entries before checking: "$numLinesUSERLIST_ORI" \
After: "$numLinesUSERLIST_after""| tee -a $TMP-USERLIST_DB.rep.head
if [ "$usrlst_uniq_errors" -gt "0" ] || [ "$usrlst_removed" -gt "0" ]; then
if [ "$usrlst_uniq_errors" -gt "0" ]; then
echo "- Corrected a total of "$usrlst_errors" "$error_s" on \
"$usrlst_uniq_errors" "$entry_s"."
fi
if [ -s $TMP-USERLIST_DB.rep.body0 ]; then
echo -e "===== Fixed userlist.db errors
(first entry on each section corresponds to the one with errors)
`cat $TMP-USERLIST_DB.rep.body0`
_______________________ end of fixed userlist.db entries \
_______________________" > $TMP-USERLIST_DB.rep.body
fi
if [ "$usrlst_removed" -gt "0" ]; then
echo "- Removed entries due to missing or irrecoverable IP: "$usrlst_removed""
echo -e "-=-=- Removed entries from userlist.db due to irrecoverable IP
`cat $TMP-USERLIST_DB.rep.body1`
_______________________ end of removed userlist.db entries \
_______________________" >> $TMP-USERLIST_DB.rep.body
fi
else
echo "- No syntax errors found."
fi | tee -a $TMP-USERLIST_DB.rep.head
# dup_entries
if [ -s $TMP.dup.entries ]; then
dupentries_lines="$(expr "$dupentries_lines" + "$dupentries_lines_1")"
dupentries_lin_rem="$(expr "$dupentries_lin_rem" + "$dupentries_lin_rem_1")"
dupentries_lin_rem="$(expr "$dupentries_lin_rem" + "$dupentries_lin_rem_1")"
cat $TMP.dup.entries >> $TMP.dup.entries_1
echo "DUPLICATE ENTRIES on "$ORIG_FILE"
- Number of entries with repetitions: "$dupentries_lines"
- Number of repetitions found: "$dupentries_lin_rem"
- Number of lines removed: "$dupentries_lin_rem"
(Check section \"Removed DUPLICATE ENTRIES from $ORIG_FILE\" on this file)"
echo -e "-=-=- Removed DUPLICATE ENTRIES from "$ORIG_FILE"" >> \
$TMP-USERLIST_DB.rep.body
cat $TMP.dup.entries_1 >> $TMP-USERLIST_DB.rep.body
echo "_______________________ end of duplicate entries on "$ORIG_FILE"\
________________________" >> $TMP-USERLIST_DB.rep.body
CHANGED=""$CHANGED" "$ORIG_FILE""
else
echo "- No repeated entries found!"
fi | tee -a $TMP-USERLIST_DB.rep.head
rm -f $TMP.dup.entries
rm -f $TMP-DUP_ENTRIES.$ORIG_FILE.rep.head
rm -f $TMP-DUP_ENTRIES.$ORIG_FILE.rep.body
SLEEP 3
# end of dup_entries report
if [ "$usrlst_uniq_errors" -gt "0" ] || [ "$usrlst_removed" -gt "0" ]; then
CHANGED=""$CHANGED" "$ORIG_FILE""
fi
SLEEP 4
}
# NOT IMPLEMENTED YET
REMOVE_PREMADE_DBS () {
echo $null
}
## END OF MAIN FUNCTIONS ##
###########################
###########
## FILES ##
################ PREP AND START
FILES_PREP () {
clear
echo -e "$PNCI\n-- Preparing $ORIG_FILE file --\n\nUsing $ORIG_FILE in a safe
temporary working file..."
SLEEP 1
if [ ! -s $ORIG_PATH ]; then
touch $ORIG_PATH
if [ "$ORIG_PATH" = "../dat/userlist.db" ]; then
echo "#channel *user_ident@*user.ip.net 1 0 password_here \
You need to !setinfo" >> "$ORIG_PATH"
fi
fi
# copy orig file to working file
cp -f $ORIG_PATH $TMP-DB.WORK.FILE
if [ "$external_db" = "DB_MASTER" ]; then
numLinesDB_MASTER=$(cat $COMMON_TMP/TMP-DB_MASTER | wc -l | tr -cd '[:alnum:]')
echo -e "\nMoving downloaded database to the info2.db working file..."
cat $COMMON_TMP/TMP-DB_MASTER >> $TMP-DB.WORK.FILE
info2db_lines="$(if [ "$numLines_info2_ORI" = "0" ]; then
echo "info2.db empty file."; else
echo "initial "$numLines_info2_ORI" info2.db lines,\nmaking a total of \
`expr "$numLinesDB_MASTER" + "$numLines_info2_ORI"` entries to be checked."; fi)"
echo -e "\n"$numLinesDB_MASTER" new entries added to your "$info2db_lines""
CHANGED=""$CHANGED" "$ORIG_FILE""
SLEEP 4
fi
numLinesORI=$(cat $TMP-DB.WORK.FILE | wc -l | tr -cd '[:alnum:]')
SLEEP 3
}
# files start
START_INFO2 () {
ORIG_FILE="info2.db"
ORIG_PATH="../dat/info2.db"
numLines_info2_ORI=$(cat $ORIG_PATH 2>/dev/null | wc -l | tr -cd '[:alnum:]')
sleep 2
# if file is not empty ...
if [ "$numLines_info2_ORI" != "0" ] || [ -n "$external_db" ]; then
FILES_PREP
LINE_FEED; EMPTY_LINES; INCOMPL_ENTRIES; DUP_ENTRIES; DUP_TOPICS
TOPIC_SIZE; DATA_SIZE; CHECK_RDBS
if echo "$CHANGED" | grep -q info2.db 1>/dev/null; then
mv -f $TMP-DB.WORK.FILE $TMP-INFO2.DB
fi
else # if is empty
clear
echo -e "$PNCI\ninfo2.db file is empty. There is no need to check it!
Add topics and replies to it so your Darkbot could "talk".\n"
SLEEP 3
fi
}
START_SERVERS () {
ORIG_FILE="servers.ini"
ORIG_PATH="../dat/servers.ini"
numLinesORI=$(cat $ORIG_PATH 2>/dev/null | wc -l | tr -cd '[:alnum:]')
# if file is not empty ...
if [ "$numLinesORI" != "0" ]; then
FILES_PREP
LINE_FEED; EMPTY_LINES;
SERVERS_INI
if echo "$CHANGED" | grep -q servers.ini 1>/dev/null; then
mv -f $TMP-DB.WORK.FILE $TMP-SERVERS.INI
fi
else # if is empty
clear
echo -e "$PNCI\nservers.ini file is empty. There is no need to check it!
You'll need to add servers so your Darkbot can connect to IRC.\n"
SLEEP 3
fi
}
START_SETUP () {
ORIG_FILE="setup.ini"
ORIG_PATH="../dat/setup.ini"
numLinesORI=$(cat $ORIG_PATH 2>/dev/null | wc -l | tr -cd '[:alnum:]')
FILES_PREP
LINE_FEED; EMPTY_LINES;
SETUP_INI
if echo "$CHANGED" | grep -q setup.ini 1>/dev/null; then
mv -f $TMP-DB.WORK.FILE $TMP-SETUP.INI
fi
}
START_PERFORM () {
ORIG_FILE="perform.ini"
ORIG_PATH="../dat/perform.ini"
numLinesORI=$(cat $ORIG_PATH 2>/dev/null | wc -l | tr -cd '[:alnum:]')
# if file is not empty ...
if [ "$numLinesORI" != "0" ]; then
FILES_PREP
LINE_FEED; EMPTY_LINES
if echo "$CHANGED" | grep -q perform.ini 1>/dev/null; then
mv -f $TMP-DB.WORK.FILE $TMP-PERFORM.INI
fi
else # if is empty
clear
echo -e "$PNCI\nperform.ini file is empty. There is no need to check it!\n"
SLEEP 3
fi
}
START_USERLIST () {
ORIG_FILE="userlist.db"
ORIG_PATH="../dat/userlist.db"
numLinesUSERLIST_ORI="$(cat $ORIG_PATH 2>/dev/null | wc -l | tr -cd '[:alnum:]')"
numLinesORI="$numLinesUSERLIST_ORI"
# if file is not empty ...
if [ "$numLinesORI" != "0" ]; then
FILES_PREP
LINE_FEED; EMPTY_LINES; DUP_ENTRIES
USERLIST_DB
if echo "$CHANGED" | grep -q userlist.db 1>/dev/null; then
mv -f $TMP-DB.WORK.FILE $TMP-USERLIST.DB
fi
else # if is empty
clear
echo -e "$PNCI\nuserlist.db file is empty. There is no need to check it!
Use AddUser to add yourself as Darkbot administrator."
SLEEP 3
fi
}
START_RANDOM () {
RANDOM_FILES
}
## END OF FILES PREP AND START ##
#################################
####################
## UPDATE PROCESS ##
FILES_BACKUP () {
# backup file
clear
echo -e "$PNCI\n- ORIGINAL FILES UPDATE -\n"
if [ -s "$2" ]; then
echo -e "Backing up your current "$1" before updating it \
with the changes made...\n"
cp -fp "$2".bak.1 "$2".bak.2 2>/dev/null
cp -fp "$2".bak.0 "$2".bak.1 2>/dev/null
mv -f "$2" "$2".bak.0
echo "Your most current $ORIG_FILE backup is "$2".bak.0"
if [ -e "$2".bak.1 ]; then
echo "You still have a previous backup on "$2".bak.1"
fi
if [ -e "$2".bak.2 ]; then
echo "and an older one as "$2".bak.2"
fi
fi
SLEEP 3
}
FILES_UPDATE () {
if [ -n "$CHANGED" ]; then
count=10; counter=1
while [ $count != "$counter" ]; do
count=`expr "$count" - 1`
clear
echo -e "$PNCI\n- ORIGINAL FILES UPDATE -\n
The changes made will be effectively updated now.
If you do not want those changes to be saved to the original files press
CTRL + C now to abort.\n
The update process will start in ["$count"] seconds...\n"
SLEEP 1
done
no_changes () {
#if echo $ci_files | grep $1; then
if [ ! -s $TMP-no.changes ]; then
echo -e "clear\necho \"$PNCI\n- ORIGINAL FILES UPDATE -\n\"" > $TMP-no.changes
fi
if echo "$ci_files" | grep -i `echo "$1" | cut -d. -f1`; then
echo -e "echo \"No changes made on your $1 $2.\"
SLEEP 1" >> $TMP-no.changes
fi
}
if [ -s $TMP-INFO2.DB ]; then
FILES_BACKUP info2.db ../dat/info2.db
echo -e "\nMoving working file to ../dat/info2.db ...\n"
mv -f $TMP-INFO2.DB ../dat/info2.db
SLEEP 1
else
no_changes info2.db file
fi
if [ -s $TMP-SERVERS.INI ]; then
FILES_BACKUP servers.ini ../dat/servers.ini
echo -e "\nMoving working file to ../dat/servers.ini ...\n"
mv -f $TMP-SERVERS.INI ../dat/servers.ini
SLEEP 1
else
no_changes servers.ini file
fi
if [ -s $TMP-SETUP.INI ]; then
FILES_BACKUP setup.ini ../dat/setup.ini
echo -e "\nMoving working file to ../dat/setup.ini ...\n"
mv -f $TMP-SETUP.INI ../dat/setup.ini
SLEEP 2
else
no_changes setup.ini file
fi
if [ -s $TMP-PERFORM.INI ]; then
FILES_BACKUP perform.ini ../dat/perform.ini
echo -e "\nMoving working file to ../dat/perform.ini ...\n"
mv -f $TMP-PERFORM.INI ../dat/perform.ini
SLEEP 2
else
no_changes perform.ini file
fi
if [ -f $TMP-USERLIST.DB ]; then
FILES_BACKUP userlist.db ../dat/userlist.db
echo -e "\nMoving working file to ../dat/userlist.db ...\n"
mv -f $TMP-USERLIST.DB ../dat/userlist.db
SLEEP 2
else
no_changes userlist.db file
fi
if [ -s $TMP-RANDOM_FILES ]; then
# do some cosmetic work on the file for backups, only on these random files
echo -e "clear\n echo -e \"$PNCI\n- ORIGINAL FILES UPDATE -\n\"" > $TMP-RANDOM_FILES_TMP
cat $TMP-RANDOM_FILES >> $TMP-RANDOM_FILES_TMP
mv -f $TMP-RANDOM_FILES_TMP $TMP-RANDOM_FILES
echo "SLEEP 1" >> $TMP-RANDOM_FILES
# go for it
echo -e "\nMoving random files to dat directory...\n"
. $TMP-RANDOM_FILES
SLEEP 2
else
no_changes random files
fi
# execute no changes messages
if [ -s $TMP-no.changes ]; then
. $TMP-no.changes
fi
fi # end of count down to update changes
SLEEP 4
}
## END OF UPDATE PROCESS ##
###########################
############
## REPORT ##
INTEGRITY_REPORT () {
if [ -s $ci_report ]; then
cp -fp $ci_report $ci_report.old
fi
_head_separator_ () {
echo "----------------------------------\
---------------------------------------" >> $ci_report
}
_head_entry_ () {
cat $1 >> $ci_report 2>/dev/null
}
# obtain numb of lines after process done
echo -e "$PNCI* Integrity Check Report File *
Generated on `date`
=========================================================================
| SUMMARY |
================================== ==================================" \
> $ci_report
_head_separator_
info2LinesFinal=$(cat ../dat/info2.db 2>/dev/null | wc -l | tr -cd '[:alnum:]')
echo "TOTAL LINES/ENTRIES on info2.db: \
Before = "$numLines_info2_ORI" Now = "$info2LinesFinal"\
`if [ "$line_feed" = "y" ]; then echo -e "\n(There is one \
additional line due to an added line feed)"; fi`" >> $ci_report
_head_entry_ $TMP-LINE_FEED.info2.db.rep.head
_head_entry_ $TMP-EMPTY_LINES.info2.db.rep.head
_head_entry_ $TMP-INCOMPL_ENTRIES.rep.head
_head_entry_ $TMP-DUP_ENTRIES.info2.db.rep.head
_head_entry_ $TMP-DUP_TOPICS.rep.head
_head_entry_ $TMP-TOPIC_SIZE.rep.head
_head_entry_ $TMP-DATA_SIZE.rep.head
_head_entry_ $TMP-CHECK_RDBS.rep.head
_head_separator_ # end of info2.db
_head_entry_ $TMP-RANDOM_FILES.rep.head
_head_separator_ # servers.ini
_head_entry_ $TMP-SERVERS_INI.rep.head
_head_entry_ $TMP-LINE_FEED.servers.ini.rep.head
_head_entry_ $TMP-EMPTY_LINES.servers.ini.rep.head
_head_separator_ # setup.ini
_head_entry_ $TMP-SETUP_INI.rep.head
_head_entry_ $TMP-LINE_FEED.setup.ini.rep.head
_head_entry_ $TMP-EMPTY_LINES.setup.ini.rep.head
_head_separator_ # perform.ini
_head_entry_ $TMP-LINE_FEED.perform.ini.rep.head
_head_entry_ $TMP-EMPTY_LINES.perform.ini.rep.head
_head_separator_ # userlist.db
_head_entry_ $TMP-USERLIST_DB.rep.head
_head_entry_ $TMP-LINE_FEED.userlist.db.rep.head
_head_entry_ $TMP-EMPTY_LINES.userlist.db.rep.head
_head_separator_
echo "
=========================================================================
| MODIFICATIONS |
================================== ==================================
" >> $ci_report
_body_entry_ () {
cat $1 >> $ci_report 2>/dev/null
}
_body_separator_ () {
echo "" >> $ci_report
}
_body_entry_ $TMP-INCOMPL_ENTRIES.rep.body
_body_separator_
_body_entry_ $TMP-DUP_ENTRIES.info2.db.rep.body
_body_separator_
_body_entry_ $TMP-DUP_TOPICS.rep.body
_body_separator_
_body_entry_ $TMP-TOPIC_SIZE.rep.body
_body_separator_
_body_entry_ $TMP-DATA_SIZE.rep.body
_body_separator_
_body_entry_ $TMP-CHECK_RDBS.rep.body
_body_separator_
_body_entry_ $TMP-SETUP_INI.rep.body
_body_separator_
_body_entry_ $TMP-USERLIST_DB.rep.body
}
## END OF REPORT ##
###################
CI_LOG_VARS () {
if [ ! -s "$ci_vars" ]; then
touch $ci_vars
fi
if [ "$1" = "topicsize" ]; then
unset TOPIC_SIZE
while [ -z "$TOPIC_SIZE" ]; do
clear
echo -e "$PNCI\n - CHANGING TOPIC LENGTH VALUE -\n\n"
echo -n "Enter the topic length to be set for this utility
(Default value for topic length is 50 characters): "
read topic_size
unset testinteger
testinteger="$(expr "$topic_size" - "0" 2>/dev/null)"
if [ ! -z "$testinteger" ]; then
TOPIC_SIZE="$topic_size"
if [ "`grep 'TOPIC_SIZE' $ci_vars`" ]; then
grep -v 'TOPIC_SIZE' $ci_vars > $TMP
cat $TMP > $ci_vars
fi
echo "TOPIC_SIZE=\"$TOPIC_SIZE\"" >> $ci_vars
echo -e "\nAdded value of "$topic_size" for maximum topic length!\n
This value MUST be the same as the one given on defines.h
when Darkbot was configured.
[ To remove this setting type $0 -default ]\n"
else
echo -e "\n#### ERROR ####\nPlease enter an integer [0-9]"
sleep 2
fi
done
SLEEP 4
fi
if [ "$1" = "replysize" ]; then
unset DATA_SIZE
while [ -z "$DATA_SIZE" ]; do
clear
echo -e "$PNCI\n - CHANGING REPLY LENGTH VALUE -\n\n"
echo -n "Enter the reply length to be set for this utility
(Default value for reply length is 400 characters): "
read reply_size
unset testinteger
testinteger="$(expr "$reply_size" - "0" 2>/dev/null)"
if [ ! -z "$testinteger" ]; then
DATA_SIZE="$reply_size"
if [ "`grep 'DATA_SIZE' $ci_vars`" ]; then
grep -v 'DATA_SIZE' $ci_vars > $TMP
cat $TMP > $ci_vars
fi
echo "DATA_SIZE=\"$DATA_SIZE\"" >> $ci_vars
echo -e "\nAdded value of "$reply_size" for maximum reply length!\n
This value MUST be the same as the one given on defines.h
when Darkbot was configured.
[ To remove this setting type $0 -default ]\n"
else
echo -e "\n#### ERROR ####\nPlease enter an integer [0-9]"
sleep 2
fi
done
SLEEP 4
fi
if [ "$1" = "nointro" ]; then
ci_intro_OnOff=off
if [ "`grep 'ci_intro_OnOff' $ci_vars`" ]; then
grep -v 'ci_intro_OnOff' "$ci_vars" > $TMP
cat $TMP > $ci_vars
fi
echo "ci_intro_OnOff=\"$ci_intro_OnOff\"" >> $ci_vars
clear
echo -e "$PNCI\n - INTRODUCTION TEXT -\n\n
Introduction is now turned off\n
[ To remove this setting type $0 -default ]\n"
SLEEP 4
fi
}
CI_INTRO_START () {
if [ ! `echo "$ci_arg" | grep 'nointro' 2>/dev/null` ]; then # \
if [ ! `echo "$ci_intro_OnOff" | grep 'off' 2>/dev/null` ]; then
if [ ! `echo "$ci_switches" | grep 'quick' 2>/dev/null` ]; then
CI_INTRO
fi
fi
fi
}
# ------------------------ START UTILITY ------------------------ #
###########
## START ##
#DB_SCRIPTS_PATH;
ENVIRONMENT; TESTDEPEND_GO
ci_files= ci_switches=
for ci_arg
do
case "$ci_arg" in
-*) ci_switches="$ci_switches $ci_arg" ;;
*) ci_files="$ci_files $ci_arg" ;;
esac
done
# not in use but left here for future consid.
case "$ci_files" in
#"") USAGE 1>&2 ;;
"") $null 1>&2 ;;
*) for file in $ci_files
do
CI_INTRO_START
done
stat=0
;;
esac
if [ -z "$ci_files" ] && [ -z "$ci_switches" ]; then
USAGE
fi
# ----- SWITCHES -----
# help __
if echo "$ci_switches" | grep -qi 'h' 1>/dev/null; then
USAGE
fi
# default __
if echo "$ci_switches" | grep -qi 'default' 1>/dev/null; then
rm -f "$ci_vars"
fi
# SLEEP function __
if echo "$ci_switches" | grep -qi 'quick' 1>/dev/null; then
# bypasses or not 'sleep' (pause) periods -- syntax= SLEEP 3
SLEEP () { SLEEP=$($null); }
# if wants quick there is no reason for intro, so... bypass INTRO
else
SLEEP () { SLEEP=$(sleep $1); }
fi
# bypasses introduction __
if echo "$ci_switches" | grep -qi 'nointro' 1>/dev/null; then
CI_LOG_VARS nointro
#else
#if [ "$ci_intro_OnOff" != "off" ]; then CI_INTRO; fi
fi
# show report __
if echo "$ci_switches" | grep -qi 'report' 1>/dev/null; then
if [ -s $ci_report ]; then
cat $ci_report | less -deXF
else
echo -e "$PNCI\n\nThere is no report file registered\n"
fi
fi
# topic length __
if echo "$ci_switches" | grep -qi 'topicsize' 1>/dev/null; then
CI_LOG_VARS topicsize
fi
# reply length __
if echo "$ci_switches" | grep -qi 'replysize' 1>/dev/null; then
CI_LOG_VARS replysize
fi
# ----- FILES -----
# do all
if echo "$ci_files" | grep -qi "all" 1>/dev/null; then
START_INFO2
START_SERVERS
START_SETUP
START_PERFORM
START_USERLIST
START_RANDOM
fi
# info2.db
if echo "$ci_files" | grep -qi 'info2' 1>/dev/null; then
START_INFO2
fi
# servers.ini
if echo "$ci_files" | grep -qi 'servers' 1>/dev/null; then
START_SERVERS
fi
# setup.ini
if echo "$ci_files" | grep -qi 'setup' 1>/dev/null; then
START_SETUP
fi
# perform.ini
if echo "$ci_files" | grep -qi 'perform' 1>/dev/null; then
START_PERFORM
fi
# userlist.db
if echo "$ci_files" | grep -qi 'userlist' 1>/dev/null; then
START_USERLIST
fi
# random.ini
if echo "$ci_files" | grep -qi 'random' 1>/dev/null; then
START_RANDOM
fi
# external databases
if echo "$ci_files" | grep -qi 'DB_MASTER' 1>/dev/null; then
external_db="DB_MASTER"
START_INFO2
fi
# remove dbs ###### NOT IMPLEMENTED YET ######
if echo "$ci_files" | grep -qi 'remove dbs' 1>/dev/null; then
# go to dd and use remove function
./download-databases
# do a pre check on info2
START_INFO2
REMOVE_PREMADE_DBS # add selected dbs to the end of info2 with a mark; run a
# dup entries function for this only where uniques and dups
# are removed; check at the end entries left after the mark
# meaning they didn't have any match ( just for info); do
# counts at the end | add actions to report
fi
# ____________________ FINAL ____________________
if [ -n "$CHANGED" ]; then
FILES_UPDATE
INTEGRITY_REPORT
echo -e "\nA file `pwd`/$ci_report was created
with the result of all actions taken during this process.
You can see it by typing $0 -report"
# rm empty lines
# clean empty
grep '.' $ci_report > $TMP-ci_report
mv -f $TMP-ci_report $ci_report
else # no changes made to any file
clear
echo -e "$PNCI\n"
if [ ! -z "$ci_files" ]; then
echo -e "\nNo changes were made to your files!\n"
fi
fi
if [ ! -z "$ci_files" ]; then
if echo "$ci_files" | grep -qi 'DB_MASTER' 1>/dev/null; then
ci_files_0="info2.db with downloaded and installed pre-made database"
else
file_s="$( if [ "`echo "$ci_files" | wc -w | tr -cd '[:alnum:]'`" -gt "1" ] \
|| `echo "$ci_files" | grep -qi 'random'`; then \
echo files; else echo file; fi)"
ci_files_0="$(echo "$ci_files" | sed -e s/[[:space:]]/''-''/g)"
fi
echo -e "\n Data integrity check process on
"[$ci_files_0-]" "$file_s" complete.\n"
fi
SLEEP 3
exit 0
diff --git a/scripts/dbcron b/scripts/dbcron
index 0c438dd..17db35c 100755
--- a/scripts/dbcron
+++ b/scripts/dbcron
@@ -1,142 +1,142 @@
#! /bin/sh
PID=0624233000
# Darkbot utility to auto generate crontab.
# Just run this script and a new one with the same name will be created
# with the actual path of your Darkbot installation. At the same time
# a crontab job will be created with 10 mins interval.
# to do: user defined timers on command line utility launch
MAKE_DBCRON () {
cat > dbcron << EOF[DBCRON]
#! /bin/sh
# Darkbot's crontab utility
DBPATH="$DBPATH" # your darkbot directory
DBBIN="$DBBIN" # Darkbot's binary (executable) file
DBPIDFILE="$DBBIN.pid" # process ID file (same as binary + .pid)
# This file was automatically generated the first time you've run dbcron.
# If for any reason you've changed your Darkbot directory or it's binary
# you'll need to modify the variables DBPATH DBBIN and DBPIDFILE on top of
# this file accordingly to the actual values.
# Defaulty crontab job is of 10 mins interval. If you wish to change it
# edit '0,10,20,30,40,50 * * * *'. If you don't understand it type 'man crontab'
# -----------------------------------------------------------------------------
# What this script does:
# Changes to darkbot root dir; if pid file exists extracts pid number;
# tests it by issuing an inoffensive kill; if pid is active exits, doing
# nothing; if not means the file with pid is there but there is no active
# process, so removes it. finally cheks if program bin exists then starts it.
# ____________ Do not change anything bellow this line! ____________#
cd \$DBPATH
if test -r \$DBPATH/\$DBPIDFILE; then
DBPID=\$(cat \$DBPATH/\$DBPIDFILE)
if \$(kill -CHLD \$DBPID >/dev/null 2>&1)
then
exit 0
fi
echo -e "\nstale pid file (erasing it)"
rm -f \$DBPATH/\$DBPIDFILE
fi
echo -e "\nDarkbot is dead! Restarting . . . . . . . .\n"
if test -x \$DBBIN ;then
\$DBPATH/\$DBBIN
exit 0
fi
echo "could not reload"
EOF[DBCRON]
}
# PREP SCRIPT
# check if it is on the right place
ABORT () {
echo -e "\nThis utility will stop now!\n\nLeav\
ing $0...\n\n\n"; sleep 1; exit 0
}
DB_SCRIPTS_PATH () {
dirutil="scripts"
filutil="`basename $0`"
# check if dir is correct
if ! echo `pwd` | grep -q "\/"$dirutil""; then
# file is not being launched from $dirutil
if [ -d "$dirutil" ]; then # dir is there
# if file is not in the correct dir
if [ ! "`ls "$dirutil" | grep "$filutil"`" ]; then
# file is not in the correct dir so move it
clear
echo -e "$PNCI\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory.\n"
echo "Moving it now...."
sleep 2
cat > db_wrong_path << EOF[WP]
mv -f $0 "$dirutil"/
cd "$dirutil"/
echo -e "\n| Your "$filutil" is now located in your "$dirutil" directory |
| Launch it from there when necessary |\n\n"
sleep 4
$0
rm -f ../db_wrong_path
exit 0
EOF[WP]
. db_wrong_path
else # file is in dir so just cd
cd "$dirutil"/
fi
else # dir is not there so don't bother - tell user to move it
clear
echo -e "$PNCI\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory and launched from there or Darkbot's root.
Please move it and launch it again."
sleep 3
ABORT
fi
fi
}
#DB_SCRIPTS_PATH
# check if crontab is present if not there is no reason to run this script
if ! type crontab >/dev/null 2>&1 ; then
echo -e "\nThis script needs 'crontab' command to run, which appears it's \
not installed on this system.
Leaving..."
exit 0
fi
#check if crond is active
if [ ! "$(ps ax | grep -v grep | grep crond 2>/dev/null)" ]; then
echo -e "\nThis script needs 'crond' running, which appears it's \
not on this system.
Leaving..."
fi
# dbcron engine creation. make vars for darkbot path, dir and pid file
DBPATH=$(cd ..; pwd)
if [ -x "$DBPATH/darkbot" ]; then
DBBIN="darkbot"
DBPIDFILE=$DBBIN.pid
# vars are done so let's tell crontab how we want it setup
# check every 10 minutes; send messages to null
# echo '0,10,20,30,40,50 * * * *' "$DBPATH/scripts/dbcron" > crontable.$$ #debug only
echo '0,10,20,30,40,50 * * * *' "$DBPATH/scripts/dbcron >/dev/null 2>&1" >> crontable.$$
crontab crontable.$$; rm -f crontable.$$
# transfer crontab engine file with new vars on top to a new file with same
# name as this one. THIS FILE CONTENTS WILL BE GONE!
MAKE_DBCRON
clear
echo -e "\n\nDarkbot crontab utility\n\nCrontab job created successfully!
To check if everything is okay, kill your bot if it is connected to IRC.
It should automatically restart in 10 minutes.\n
Suggestions, improvements?
-Support: http://forum.freezedown.org\n\n"
+Support: http://darkbot.sourceforge.net\n\n"
else
echo -e "\nDarkbot's Crontab Utility.
WARNING!!!!\nDarkbot's binary not found.
Please run ./configure if you haven't do so or restore \
file names to it's default values.\n
Leaving $0..."
exit 0
fi
diff --git a/scripts/download-databases b/scripts/download-databases
index 68fff80..ce87a6e 100755
--- a/scripts/download-databases
+++ b/scripts/download-databases
@@ -1,384 +1,384 @@
#!/bin/sh
PNDD="Darkbot's pre-made Databases Utility\n<****************_~_****************>\n"
PID=0624233000
# todo -- download tars as of live-update instead of *.db
# removal of pre-made databases (in conjunction w/check-integrity)
ABORT () {
echo -e "\nThis utility will stop now!\n\nLeav\
ing $PN...\n\n\n"; sleep 1; exit 0
}
DB_SCRIPTS_PATH () {
dirutil="scripts"
filutil="`basename $0`"
# check if dir is correct
if ! echo `pwd` | grep -q "\/"$dirutil""; then
# file is not being launched from $dirutil
if [ -d "$dirutil" ]; then # dir is there
# if file is not in the correct dir
if [ ! "`ls "$dirutil" | grep "$filutil"`" ]; then
# file is not in the correct dir so move it
clear
echo -e "$PNCI\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory.\n"
echo "Moving it now...."
sleep 2
cat > db_wrong_path << EOF[WP]
mv -f $0 "$dirutil"/
cd "$dirutil"/
echo -e "\n| Your "$filutil" is now located in your "$dirutil" directory |
| Launch it from there when necessary |\n\n"
sleep 4
$0
rm -f ../db_wrong_path
exit 0
EOF[WP]
. db_wrong_path
else # file is in dir so just cd
cd "$dirutil"/
fi
else # dir is not there so don't bother - tell user to move it
clear
echo -e "$PNCI\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory and launched from there or Darkbot's root.
Please move it and launch it again."
sleep 3
ABORT
fi
fi
}
#DB_SCRIPTS_PATH
ENVIRONMENT () {
BASE_WORKDIR=.scriptutils
COMMON_TMP=$BASE_WORKDIR/tmp
mkdir -p $BASE_WORKDIR/tmp
DDDIR=$BASE_WORKDIR/dldatabases
TMP=$BASE_WORKDIR/._tmp/ddat$$
mkdir -p $BASE_WORKDIR/._tmp/
DD_LOGFILE=$BASE_WORKDIR/.dbs_status
cp -f $DD_LOGFILE $TMP-DBS_STATUS 2>/dev/null
trap 'rm -f $TMP* >/dev/null; rm -fr $BASE_WORKDIR/._* >/dev/null 2>&1' 0
m_trap="echo -e \n\n -- `basename $0` terminated by `whoami` --\n\n"
trap '$m_trap 1>&2; exit' 1 2 3 13 15
}
# test dependencies
TESTDEPEND () {
NonFatalError () {
echo "FATAL ERROR at $0 (`date`): $FiLe not detected \
on this system." >> $BASE_WORKDIR/error_messages
clear
echo -e "$PNDD\nFATAL ERROR at $0 (`date`)\n\n
$FiLe not detected on this system.
It is essential for $0 to work properly."
ABORT
}
if ! (type "$1" 1>/dev/null 2>&1); then
FiLe="$1"
NonFatalError $1
sleep 1; unset $FiLe
fi
}
TESTDEPEND_GO () {
TESTDEPEND "grep"; TESTDEPEND "sed"; TESTDEPEND "cut"
TESTDEPEND "wc"; TESTDEPEND "cat"; TESTDEPEND "expr"
}
# test dependencies which can have optional programs and set vars for those.
TESTDEPEND_SUBST () {
# test lynx/wget
if (type "lynx" 1>/dev/null 2>&1); then
dld_prg="lynx"
else
if (type "wget" 1>/dev/null 2>&1); then
dld_prg="wget"
fi
fi
if [ -z "$dld_prg" ]; then
echo -e "FATAL ERROR at $0 (`date`): lynx and wget not detected \
on this system. One it's necessary for this utility to work \
properly" >> $BASE_WORKDIR/error_messages
clear
echo -e "$PN\nFATAL ERROR at $0 (`date`)\n\n
Either lynx or wget are essential for $0 to work properly.
None of those programs were found on this system"
ABORT
fi
}
# download command line to parse redirection url
GET_SERVER_URLS () {
if [ "$dld_prg" = "lynx" ]; then
-lynx -source http://www.freezedown.org 2>/dev/null > $TMP
+lynx -source http://darkbot.sourceforge.net 2>/dev/null > $TMP
else
-wget -qO $TMP http://www.freezedown.org
+wget -qO $TMP http://darkbot.sourceforge.net
fi
-# parse redir. main url. ex: http://pincel.net/darkbot/
+# parse redir. main url. ex: http://darkbot.sourceforge.net
REDIRECT_URL_MAIN=$(grep "FRAME SRC" $TMP | cut -d\" -f2)
-# redirection url for dbs. ex: http://pincel.net/darkbot/arquive/databases/
+# redirection url for dbs. ex: http://darkbot.sourceforge.net/arquive/databases/
REDIRECT_URL_DBS=""$REDIRECT_URL_MAIN"archive/databases"
if [ ! -s $TMP ]; then
clear
echo -e "$PNDD\nWARNING\n
Unable to establish connection with the server."
ABORT; fi
}
# get dbs info text
# download command line to parse redirection url
GET_DBS_INFO () {
if [ "$dld_prg" = "lynx" ]; then
lynx -dump -nolist "$REDIRECT_URL_MAIN"databases.html > $TMP-db.txt
else
wget -qO $TMP-db.txt "$REDIRECT_URL_MAIN"databases.html
fi
if ! grep -qwi "Pre-made" $TMP-db.txt 2>/dev/null; then
clear
echo -e "$PNDD\nWARNING\n
Unable to obtain from the server essential information."
ABORT; fi
}
# get vars -- Database=acro2
GET_DBS_VARS () {
if [ "$dld_prg" = "lynx" ]; then
cat $TMP-db.txt | sed -ne /Elaborated/s/[[:blank:]]*/Database=/p \
| cut -d ' ' -f1 | cut -d. -f1 > $TMP.db.vars
else
sed -ne /zip[\<a*]/s/[[:blank:]]*/Database=/p $TMP-db.txt \
| cut -d. -f1 > $TMP.db.vars
fi
}
# download status; evaluate user activity; check if any new database
# register activity in local file
DBS_STATUS () {
rm -f $TMP-DISPLAY # refresh list
numLines="$(cat $TMP.db.vars | wc -l | sed s/[[:blank:]]*//)"
count="0"
while [ "$count" != "$numLines" ]; do
count=`expr $count + 1`
sed -n "$count"p $TMP.db.vars > $TMP.db.var
unset Database
. $TMP.db.var
# get complete local line if exists and put it on a file list
grep -w "$Database" $TMP-DBS_STATUS 2>/dev/null > $TMP.db.loc.var
# check the status and put the result on an organized list to display
if [ -s $TMP.db.loc.var ]; then
if grep -w "{D}" $TMP.db.loc.var 1>/dev/null; then
echo "[$count] {D} $Database -`cat $TMP.db.loc.var | cut -d- -f2`" >> $TMP-DISPLAY; fi
if grep "{I}" $TMP.db.loc.var 1>/dev/null; then
echo "[$count] {I} $Database" >> $TMP-DISPLAY; fi
if grep "{x}" $TMP.db.loc.var 1>/dev/null; then
echo "[$count] {x} $Database -`cat $TMP.db.loc.var | cut -d- -f2`" >> $TMP-DISPLAY; fi
else
echo "[$count] {A} $Database" >> $TMP-DISPLAY
fi
done
# prep file to be used on live-update
cat $TMP-DISPLAY | grep -w "{A}" | cut -d\} -f2 > $COMMON_TMP/.dbs_available
} # end of DBS_STATUS
DBS_STATUS_FINAL () {
# move all new dbs status to local status file
rm -f $DD_LOGFILE
# extract all but {A} without list number
cut -d' ' -f2- $TMP-DISPLAY | grep -v "{A}" > $TMP-DISPLAY1
# extract {I} and add to local
grep "{I}" $TMP-DISPLAY1 >> $DD_LOGFILE
# extract old {D} and add to local
grep "{D}" $TMP-DISPLAY1 >> $DD_LOGFILE
# move newly download entries to local
cat $TMP-DISPLAY2 2>/dev/null >> $DD_LOGFILE
}
# MENU and DOWNLOAD
DBS_MENU_DLD () {
while [ -z $LEAVENOW ]; do
DBS_STATUS
clear
# menu
# start by listing dbs by number and corresponding db, ex: 1 acro2.db
echo -e "$PNDD\nAvailable Databases:
( {A}=Available {D}=Downloaded {I}=Ignored {x}=Marked for Installation )
`#cut -d= -f2 $TMP.db.vars | cat -b`
`cat $TMP-DISPLAY`
------------------------------------
[I] Ignore databases
`if [ "$dld_prg" = "lynx" ]; then echo -e " [R] Read Databases information"; fi`
[Q] Quit "$Quit_txt"" | less -deXF
echo -n "
Please make your choice. To select databases write their corresponding
numbers, separated by spaces or commas, ie, 1,2,5 or 1 2 5: "
read CHOICE
# outputs 1 2 3 etc corresponding to database number or I/X
# dbs to be ignored
_DBS_IGNORE () {
clear
echo -e "$PNDD\nIgnore Databases\n
This feature is only useful when $0 is being used
during live-update process so the utility will not prompt for available
pre-made databases on non wanted files.\n"
echo -n "Enter the number corresponding to the database to be ignored
or write 'ALL' to mark all {A}vailable databases as {I}gnored: "
read CHOICE_I
# mark all ignored
if echo "$CHOICE_I" | grep -qwi all 1>/dev/null; then
sed s/{A}/{I}/g $TMP-DISPLAY > $TMP
cat $TMP | cut -d' ' -f2- > $TMP-DBS_STATUS
fi
# if choice is a number
sed -n "$CHOICE_I"p $TMP.db.vars 2>/dev/null > $TMP.db.vari
. $TMP.db.vari
#check if it is marked other way than {A}. (for {D} or {x})
if [ "$CHOICE_I" != "all" ] || [ "$CHOICE_I" != "uuu" ] ; then
grep -wi "$Database" $TMP-DISPLAY > $TMP
if grep -qwi "{D}" $TMP 2>/dev/null; then
echo -e "\nDatabase $Database is marked as {D}ownloaded!\n"; sleep 2
elif grep -qwi "{x}" $TMP; then
echo -e "\nDatabase $Database is {x} marked for installation!\n"; sleep 2
else # is marked as {A} so {I}gnore
echo "{I} $Database" >> $TMP-DBS_STATUS
fi
fi # if not all or uuu
} # end of _DBS_IGNORE (Ignore options)
if echo $CHOICE | grep -qwi i 1>/dev/null; then _DBS_IGNORE; fi
# [r]ead info about the files
if echo $CHOICE | grep -qwi r 1>/dev/null; then
clear
echo -e "$PNDD\nAvailable database files information\n
`grep Elaborated $TMP-db.txt | less -deX`
\nPress ENTER to continue"
read PTR
fi
# [q]uits databases utility and start integrity check in case there is any {x}
if echo $CHOICE | grep -qwi q 1>/dev/null; then
# check if $TMP-DISPLAY2 exists (created if there is any {x}download)
if [ ! -s $TMP-DISPLAY2 ]; then # no files to download so log other changes
DBS_STATUS_FINAL
fi
LEAVENOW=end
fi
DB_SELECT_DLD () {
# check how many lines on the remote list
numLines="$(cat $TMP.db.vars | wc -l | sed s/[[:blank:]]*//)"
# set max = total number/lines
max="$numLines"; count="0"
while [ $count != $max ]; do
count=`expr $count + 1`
# if CHOICE is between the range of num lines/items to choose
if (echo $CHOICE | grep -qw "$count" 1>/dev/null); then
# extract corresponding line from vars file
sed -n "$count"p $TMP.db.vars > $TMP.db.var
# then extracs var itself, ie Database=whatever
. $TMP.db.var
DLD_PRG_COMMLINE4 () {
clear; echo -e "\n$PNDD\n
\n* ========== > Downloading $Database pre-made database > > > >\n\nPlease wait..."
if [ "$dld_prg" = "lynx" ]; then
lynx -source "$REDIRECT_URL_DBS/$Database".db >> $TMP-DB_MASTER
else
wget -qO $TMP-DB_MASTER "$REDIRECT_URL_DBS"/"$Database".db
fi
# add database to log file
echo "{x} $Database - (marked for installation)" >> $TMP-DBS_STATUS
# prepare log entry in case the process finishes
echo "{D} $Database - `date +%D`" >> $TMP-DISPLAY2
# just a var for QUIT text
Quit_txt="and proceed with check integrity and final installation."
}
# check if it was ignored
if grep -w "$Database" $TMP-DBS_STATUS 2>/dev/null | grep -qw "{I}"; then
clear
echo -e "$PNDD\n
Removing [I]gnored status from "$Database"..."
sleep 2
grep -wv $Database $TMP-DBS_STATUS > $TMP
cat $TMP > $TMP-DBS_STATUS
fi
# check if it was downloaded already
if grep -w "$Database" $TMP-DBS_STATUS 2>/dev/null | grep -qw "{D}"; then
clear
echo -e "$PNDD\n
Looks like you have already downloaded database
`grep -w "$Database" $TMP-DBS_STATUS`.\n"
echo -n "Download it again? [(y)es or (n)o]: "
unset yesno1
read yesno1
case $yesno1 in
y* | Y*)
input1=y;;
n* | N*)
input1=n;;
esac
# if Y remove from list; download
if [ "$input1" = "y" ]; then
grep -wv $Database $TMP-DBS_STATUS > $TMP
cat $TMP > $TMP-DBS_STATUS
DLD_PRG_COMMLINE4
fi
else # means is a 1st download
DLD_PRG_COMMLINE4
fi # end of if database is in status list
fi
done
} # end DB_SELECT_DLD
DB_SELECT_DLD
done
} # DBS_MENU_DLD
DBS_FINALS () {
if [ -s $TMP-DB_MASTER ]; then
DBS_STATUS_FINAL
if [ -s check-integrity ]; then
cat $TMP-DB_MASTER > $COMMON_TMP/TMP-DB_MASTER
./check-integrity DB_MASTER
else
if [ -s ../dat/external_databases ]; then
mv -f ../dat/external_databases ../dat/external_databases.old
fi
cat $TMP-DB_MASTER > ../dat/external_databases
clear
echo -e ""$PNDD"\nDownloaded database is now at ../dat/external_databases\n
Move it to your info2.db file by writing
cat external_databases >> info2.db\n\n"
fi
fi
}
if [ "$1" = "-s" ]; then
ENVIRONMENT
TESTDEPEND_GO
TESTDEPEND_SUBST
GET_SERVER_URLS
GET_DBS_INFO
GET_DBS_VARS
DBS_STATUS
else
ENVIRONMENT
TESTDEPEND_GO
TESTDEPEND_SUBST
GET_SERVER_URLS
GET_DBS_INFO
GET_DBS_VARS
DBS_MENU_DLD
DBS_FINALS
fi
diff --git a/scripts/live-update b/scripts/live-update
index 4dac75f..c9e70a0 100755
--- a/scripts/live-update
+++ b/scripts/live-update
@@ -1,552 +1,552 @@
#!/bin/sh
PNLU="Darkbot Live-Update"
PN2="
$PNLU
<*******_~_*******>
"
PID=0624233000
USAGE () {
echo -e >&2 "\n$PNLU - Updates Darkbot program.\n
This program basically does the following: checks directory and file
integrity; contacts Darkbot site and downloads latest information;
compares recent information with the one installed; updates local
installation if necessary or display messages from the developers.\n
Usage: <program> -[option]
"$0" (with no option/flag) executes the program
"$0" -u Undo last changes
"$0" -n News - (latest news, usually related to updates)
"$0" -v (v0, v1, v2) Verbose mode. [currently - `if [ "$verbose" = "" ]; then echo "1"; else echo "$verbose"; fi`] *
"$0" -h Help information (this one)
"$0" -o "$PNLU" execution ON/OFF [currently `if [ "$livupd_OnOff" != "OFF" ]; then echo "ON"; else echo "OFF"; fi`] *\n
* - By switching this utility OFF you'll not be able to
receive live updates from Darkbot's site.
* - Settings for verbose: 0=stealth/silent; 1=minimal messages (default,
no prompts if no updates present); 2=all available messages\n
- Support: http://forum.freezedown.org\n"
+ Support: http://darkbot.sourceforge.net\n"
exit 1
}
ABORT () {
echo -e "\nThis utility will stop now!\n\nLeav\
ing $PNLU...\n\n\n"; sleep 1; exit 0
}
DB_SCRIPTS_PATH () {
dirutil="scripts"
filutil="`basename $0`"
# check if dir is correct
if ! echo `pwd` | grep -q "\/"$dirutil""; then
# file is not being launched from $dirutil
if [ -d "$dirutil" ]; then # dir is there
# if file is not in the correct dir
if [ ! "`ls "$dirutil" | grep "$filutil"`" ]; then
# file is not in the correct dir so move it
clear
echo -e "$PNCI\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory.\n"
echo "Moving it now...."
sleep 2
cat > db_wrong_path << EOF[WP]
mv -f $0 "$dirutil"/
cd "$dirutil"/
echo -e "\n| Your "$filutil" is now located in your "$dirutil" directory |
| Launch it from there when necessary |\n\n"
sleep 4
$0
rm -f ../db_wrong_path
exit 0
EOF[WP]
. db_wrong_path
else # file is in dir so just cd
cd "$dirutil"/
fi
else # dir is not there so don't bother - tell user to move it
clear
echo -e "$PNCI\n\n##### WARNING #####\n\n"$filutil" must be located \
in "$dirutil" directory and launched from there or Darkbot's root.
Please move it and launch it again."
sleep 3
ABORT
fi
fi
}
#DB_SCRIPTS_PATH
ENVIRONMENT () {
# set environment dirs and vars
BASE_WORKDIR=.scriptutils
COMMON_TMP=$BASE_WORKDIR/tmp
mkdir -p $BASE_WORKDIR/tmp
LUDIR=$BASE_WORKDIR/liveupdate
TMP=$LUDIR/._tmp/lu$$
mkdir -p $LUDIR/._tmp/
if [ -e "$LUDIR/.l_vars" ]; then
. "$LUDIR/.l_vars"; fi
trap 'rm -fr $COMMON_TMP >/dev/null; rm -fr $TMP* >/dev/null; \
rm -fr $LUDIR/._* >/dev/null 2>&1' 0
m_trap="echo -e \n\n -- `basename $0` terminated by `whoami` --\n\n"
trap '$m_trap 1>&2; exit' 1 2 3 13 15
}
# test dependencies
TESTDEPEND () {
NonFatalError () {
echo "FATAL ERROR at $0 (`date`): $FiLe not detected \
on this system." >> $BASE_WORKDIR/error_messages
clear
echo -e "$PNLU\nFATAL ERROR at $0 (`date`)\n\n
$FiLe not detected on this system.
It is essential for $0 to work properly."
ABORT
}
if ! (type "$1" 1>/dev/null 2>&1); then
FiLe="$1"
NonFatalError $1
sleep 1; unset $FiLe
fi
}
TESTDEPEND_GO () {
TESTDEPEND "grep"; TESTDEPEND "sed"; TESTDEPEND "cut"; TESTDEPEND "tar"
TESTDEPEND "wc"; TESTDEPEND "cat"; TESTDEPEND "expr"; TESTDEPEND "head"
}
TESTDEPEND_GO
# test dependencies which can have optional programs and set vars for those.
TESTDEPEND_SUBST () {
# test lynx/wget
if (type "lynx" 1>/dev/null 2>&1); then
dld_prg="lynx"
else
if (type "wget" 1>/dev/null 2>&1); then
dld_prg="wget"
fi
fi
if [ -z "$dld_prg" ]; then
echo -e "FATAL ERROR at $0 (`date`): lynx and wget not detected \
on this system. One it's necessary for this utility to work \
properly" >> $BASE_WORKDIR/error_messages
clear
echo -e "$PNLU\nFATAL ERROR at $0 (`date`)\n\n
Either lynx or wget are essential for $0 to work properly.
None of those programs were found on this system"
ABORT
fi
}
TESTDEPEND_SUBST
YESNO() {
# usage -- YESNO "question..?"
# if [ "$YESNO_ANSWER" = "n" -o "$YESNO_ANSWER" = "N" ]; then echo no; fi
# y/n function - Returns: 0 (true) = yes; 1 (false) = no
YESNO_DFLT=y # Set default: -y = yes; -n = no; otherwise no default
# options & args
for YESNO_OPT do
case "$YESNO_OPT" in
-[yY]*) YESNO_DFLT='y' ;;
-[nN]*) YESNO_DFLT='n' ;;
--) shift; break ;;
-*) ;;
*) break
esac
shift
done
YESNO_PROMPT="$*"
# get the response
while : ; do
echo -n "$YESNO_PROMPT (y/n)?${YESNO_DFLT:+ [$YESNO_DFLT]} " >&2
read YESNO_ANSWER YESNO_JUNK
: ${YESNO_ANSWER:=$YESNO_DFLT}
case "$YESNO_ANSWER" in
[yY]*)
#echo "YES ANSWER"
return 0
;;
[nN]*)
#echo "NO ANSWER"
return 1
;;
*)
clear
echo -e "$PN2\n\nERROR: invalid entry!\n
PLEASE press ENTER or type Y (Yes) to proceed or N (No) or CTRL+C to abort.
..." >&2
esac
done
return
}
###### LOGS ######
LOG_VARS () {
echo "livupd_OnOff=\"$livupd_OnOff\"" > $LUDIR/.l_vars
echo "WarnOnOff=\"$WarnOnOff\"" >> $LUDIR/.l_vars
echo "verbose=\"$verbose\"" >> $LUDIR/.l_vars
echo "l_livupdID=\"$livupdID\"" >> $LUDIR/.l_vars
echo "loc_Revision=\"$Revision\"" >> $LUDIR/.l_vars
echo "prev_Revision=\"$l_version\"" >> $LUDIR/.l_vars
echo "LastUpdate=\"`date`\"" >> $LUDIR/.l_vars
echo "l_db_dir=\"$l_db_dir\"" >> $LUDIR/.l_vars
}
LOG_NEWS () {
if [ -z "$TMP-livupd" ]; then
echo "No NEWS available from last update." > $LUDIR/.l_news
else
. $TMP-livupd -n > $LUDIR/.l_news
fi
}
INTEGRITY () {
if [ -d "../source" ]; then
if [ "`ls -l ../source 2>/dev/null | grep '[ch]$'`" != "" ]; then
l_sourceDir="../source"; dat="../dat"; docs="../docs"; scripts="../scripts"
l_db_dir=`pwd | cut -d/ -f4`
else
clear
echo -e "$PN2\n\nWARNING!!!!\n\n No source files found!\n"
ABORT
fi
else
if [ -e "../darkbot.c" ]; then
l_sourceDir=".."; dat="../dat"; docs="../docs"; scripts="../scripts"
l_db_dir=`pwd | cut -d/ -f4`
else
clear
echo -e "$PN2\n\nWARNING!!!!\n\n No source files found!\n"
ABORT
fi
fi #source exists
}
REMOTE1 () {
# download command line
DLD_PRG_COMMLINE () {
-updater="http://updater.darkbot.info"
+updater="http://darkbot.sourceforge.net/project_utils"
#updater="http://192.168.1.10/ongoing/.livupd"
if [ "$dld_prg" = "lynx" ]; then
lynx -source "$updater" > $TMP-livupd
else
wget -qO $TMP-livupd "$updater"
fi
}
#get remote updater
if [ "$verbose" = "2" ]; then clear
echo -e "$PN2\n
Contacting Darkbot site.\n\n
Please wait..."
sleep 3
else 1>&2; fi
trymax="3"; trycount="0"
while [ "$trycount" != "$trymax" ] && [ ! -s $TMP-livupd ]; do
trycount=`expr $trycount + 1`
########################################################
DLD_PRG_COMMLINE
#cp -f .livupd $TMP-livupd # debug only
done
if [ "$verbose" = "2" ]; then clear
echo -e "$PN2\n
Connection with Darkbot site established.
Retrieving the most recent information...\n
Please wait"
sleep 3
else 1>&2
fi
}
CHECK_PREMADE_DBS () {
# check for pre-made databases
if [ "$check_pre_made_dbs" != "complete" ]; then
./download-databases -s
if [ -s $COMMON_TMP/.dbs_available ]; then
rm -f $COMMON_TMP/.dbs_available
clear
echo -e "$PN2\n
Detected pre-made databases available for download!\n\n"
YESNO " Run pre-made databases download utility?
[ ENTER or Y (Yes); N (No) or CTRL+C to abort ]"
if [ "$YESNO_ANSWER" = "n" -o "$YESNO_ANSWER" = "N" ]; then
clear
echo -e "$PN2\nIf you want to avoid $0 detecting available databases
select 'I' on ./download-databases to ignore them.\n
Bypassing pre-made databases download utility...\n
[ Hit ENTER to continue ]\n"
read PTR
else
echo -e "\nPlease wait..."; sleep 1
./download-databases
echo -e "Pre-made databases check complete!\n\n"
sleep 3
check_pre_made_dbs=complete
fi
fi
fi
} # end of check/pre-made databases
REMOTE2 () {
if [ "$verbose" = "2" ]; then clear
echo -e "$PN2\n
Information with latest updates received.
Comparing local information with the current one from the site...\n
Please wait"
sleep 3
else 1>&2
fi
# change local id vars so remote ones will not colide
# check remote vars
. $TMP-livupd -cvars 2>/dev/null
if [ ! -z "$livupdID" ]; then
# remote file id not null so proceed
if [ "$l_livupdID" != "$livupdID" ]; then
# local file id != same as remote one so there's something new
if [ ! -z "$loc_Revision" ]; then
if [ "$loc_Revision" != "$Revision" ]; then
# local revision != same as remote so there is a new program release
if [ "$verbose" != "0" ]; then clear
echo -e "$PN2\n
New Release Update detected!\n
You have Darkbot $loc_Revision installed.
Most recent release is Darkbot $Revision.\n\n"
YESNO " Read information about it?
[ENTER or Y (Yes) to read it or N (No) not to. CTRL+C aborts]"
if [ "$YESNO_ANSWER" != "n" ]; then
if [ "$YESNO_ANSWER" != "N" ]; then
# display news
. $TMP-livupd -n
YESNO "
..............
Proceed?
[ ENTER or Y (Yes) to proceed; N (No) or CTRL+C to abort ]"
if [ "$YESNO_ANSWER" = "n" -o "$YESNO_ANSWER" = "N" ]; then ABORT; fi
fi
fi # yes/no answer is no
else 1>&2; fi # verbose = 0
# run remote updater
. $TMP-livupd -s
else
if [ "$loc_Revision" = "$Revision" ]; then
if [ "$verbose" != "0" ]; then clear; echo -e "$PN2\n
You are running Darkbot "$Revision", latest release."
sleep 1
else 1>&2; fi
fi
# local revision is the same as remote but still there's something new
# first display news then run optional updater; this optional script can
# also have small updates or non source ones, like new database
if [ "$verbose" != "0" ]; then #clear
echo -e "\n There are some NEWS from Darkbot's developers
regarding your Darkbot $loc_Revision!\n"
YESNO " Read it?
[ ENTER or Y (Yes) to proceed; N (No) or CTRL+C to abort ]"
if [ "$YESNO_ANSWER" = "n" -o "$YESNO_ANSWER" = "N" ]; then ABORT; fi
else 1>&2; fi # verbose = 0
. $TMP-livupd -n
. $TMP-livupd -o
LOG_VARS
LOG_NEWS
fi
else # missing local revision
if [ "$verbose" = "2" ]; then clear
echo -e "$PN2\n
Unable to obtain local revision ID
Most probably due to misplaced or adulterated source files.\n"
ABORT
else 1>&2; fi
fi
else # files ids are the same
if [ "$verbose" = "2" ]; then clear
echo -e "$PN2\n
No news or updates available!\n\n
Leaving $PNLU..."
echo -e "\n\n"
sleep 3
else 1>&2; fi
exit 0
fi
else # no remote file id present so we didn't get the file or arrived corrupted
if [ "$verbose" = "2" ]; then clear
echo -e "$PN2\n
Unable to compare information at this time.
most probably due to misplaced source files or adulterated version.\n
Leaving $0...\n"
sleep 3
else 1>&2; fi
exit 0
fi
}
###### STARTING & LIVE-UPDATE SETTINGS ######
VERBOSE () {
if [ ! -z "$1" ]; then # means choice is 0, 1 or 2
if [ "$verbose" != "$1" ]; then
verbose="$1"
LOG_VARS
fi
clear
echo -e "$PN2\n\n Switch value on $PNLU for verbose mode is now [\
`if [ "$verbose" = "" ]; then echo "1"; else echo "$verbose"; fi`] \n"
if [ "$verbose" = "0" ]; then
echo -e " which means, NO $PNLU program messages will be shown.
Recommended setting is 1 (minimal display of messages).\n
NOTE: have in mind, by deactivating \""$PNLU"\" functioning
messages you'd might miss important information!\n"
fi
if [ "$verbose" = "1" ]; then
echo -e " which means, MINIMAL but essential program messages will be shown.\n"
fi
if [ "$verbose" = "2" ]; then
echo -e " which means, ALL program messages will be shown.\n"
fi
else clear # choice was v or V (var $1 null)
echo -e "$PN2\n\n $PNLU verbose mode is currently on value [\
`if [ "$verbose" = "" ]; then echo "1"; else echo "$verbose"; fi`] \n"
fi
echo -e " Possible options/values are:
$0 -v Displays verbose status.
$0 -v0 Turns all messages off. (stealth mode - Not recommendable)
$0 -v1 Runs with essential messages. ( default - Recommended)
$0 -v2 Runs with all available program messages.
-------------------------------------------------
* option 0 will not run the engine on the background and not all messages will
be hidden, specially the ones involving the actual update process, because
we want you to know what's going into your computer.\n\n"
exit 1
}
LIVUPDONOFF () {
if [ "$livupd_OnOff" = "ON" ] || [ -z "$livupd_OnOff" ]; then
livupd_OnOff=OFF
else
livupd_OnOff=ON
fi
LOG_VARS
clear
echo -e "$PN2\n\nON/OFF program switch is now turned "$livupd_OnOff".\n"
if [ "$livupd_OnOff" = "OFF" ]; then
echo -e "NOTE: have in mind, by deactivating \""$PNLU"\"
you'll not be able to receive live updates!\n\n"
fi
if [ "$livupd_OnOff" = "ON" ]; then
echo -e " To run "$PNLU" just type $0\n\n"
fi
exit 1
}
WARNONOFF () {
if [ "$WarnOnOff" = "ON" ] || [ -z "$WarnOnOff" ]; then
WarnOnOff=OFF
else
WarnOnOff=ON
fi
LOG_VARS
clear
echo -e "$PN2\n\nON/OFF switch WARNING message is now turned "$WarnOnOff"\n"
if [ "$WarnOnOff" = "OFF" ]; then
echo -e "which means you can't receive live updates from Darkbot's site.\n
**** It's recommendable reactivating it by writing $0 -o
* You can see a short program usage help by typing $0 -h
* If you don't want to see this warning again type $0 -W
**************************************************\n\n"
fi
exit 1
}
#__________________________________________________________________
### START ENGINE ###
ENVIRONMENT
# switches
if [ "$1" = "-n" ] || [ "$1" = "-N" ]; then
if [ -e "$LUDIR/.l_news" ]; then clear
cat $LUDIR/.l_news | less -de; exit 1
else clear
echo -e "$PN2\n\n Sorry, no news available.\n\n"
exit 1
fi
fi
if [ "$1" = "-u" ] || [ "$1" = "-U" ]; then
if [ -e "$LUDIR/.l_undo" ]; then
clear
echo -e "$PN2\n\n This operation will restore your Darkbot as it was \
before latest
update ($LastUpdate - Darkbot $prev_Revision -> $loc_Revision).
All $PNLU settings will return to it's defaults.\n"
YESNO " Are you sure you want to reverse your changes?
[ ENTER or Y (Yes) to proceed; N (No) or CTRL+C to abort ]"
if [ "$YESNO_ANSWER" = "n" -o "$YESNO_ANSWER" = "N" ]; then ABORT; fi
tar -zxf $LUDIR/back.tar.gz -C $LUDIR
. $LUDIR/.l_undo
clear
echo -e "$PN2\n\n Changes reversed to their previous state.\n
$PNLU returned to it's default mode.\n\n"
rm -fr $LUDIR
exit 1
else clear
echo -e "$PN2\n\n Sorry, no UNDO CHANGES available.\n\n"
if [ ! -z "$loc_Revision" ]; then
echo -e " This utility was last used on $LastUpdate
during Darkbot $prev_Revision to $loc_Revision live update.
To see information about last update type $0 -n\n\n"; fi
exit 1
fi
fi
if [ "$1" = "-v" ] || [ "$1" = "-V" ]; then VERBOSE; fi
if [ "$1" = "-v0" ]; then VERBOSE 0; fi
if [ "$1" = "-v1" ]; then VERBOSE 1; fi
if [ "$1" = "-v2" ]; then VERBOSE 2; fi
if [ "$1" = "-h" ] || [ "$1" = "--h" ]; then clear; USAGE; fi
if [ "$1" = "-o" ] || [ "$1" = "-O" ]; then LIVUPDONOFF; fi
if [ "$1" = "-w" ] || [ "$1" = "-W" ]; then WARNONOFF; fi
if [ -z "$livupd_OnOff" ] || [ "$livupd_OnOff" != "OFF" ]; then
# if no vars present this is a first time
if [ ! -e "$LUDIR/.l_vars" ]; then
clear
echo -e "$PN2\n
Welcome to $PNLU engine.
Looks like this is your first time running this utility
(or you've reversed to it's defaults any previous changes).\n
For help on $PNLU options exit and type $0 -h
or press ENTER to proceed with update process.
If there are no updates available this utility will exit with
no messages.\n"
YESNO " Proceed?
[ ENTER or Y (Yes) to proceed; N (No) or CTRL+C to exit ]"
if [ "$YESNO_ANSWER" = "n" -o "$YESNO_ANSWER" = "N" ]; then ABORT; fi
fi
INTEGRITY
if [ ! -z "$l_sourceDir" ]; then
REMOTE1
if [ -s download-databases ]; then CHECK_PREMADE_DBS; fi
fi
# check if update file came
if [ ! "`grep livupdID $TMP-livupd 2>/dev/null`" ]; then
if [ "$verbose" = "2" ]; then clear
echo -e "$PN2\n\nUnable to retrieve update information.
Leaving....\n\n"
else 1>&2
fi
exit 0
fi
if [ ! -z "$TMP-livupd" ]; then REMOTE2
fi
if [ "$remote_end" = "end" ]; then LOG_VARS; LOG_NEWS
exit 0
fi
else # program is off by user choice so.. exit with a warning
if [ -z "$WarnOnOff" ] || [ "$WarnOnOff" != "OFF" ]; then
clear
echo -e "$PN2\n\nWARNING\n
$PNLU is inactive (OFF)
which means you can't receive live updates from Darkbot's site.\n
**** It's recommendable reactivating it by writing $0 -o
* You can see a short program usage help by typing $0 -h
* If you don't want to see this warning again type $0 -W
**************************************************\n\n"
fi
fi
exit 0
diff --git a/source/chansrv.c b/source/chansrv.c
index 617eb2a..60d89c1 100644
--- a/source/chansrv.c
+++ b/source/chansrv.c
@@ -1,2530 +1,2530 @@
#include "defines.h"
#include "vars.h"
#include "prototypes.h"
// FIXME: When the command is invoked in a channel, target is the channel name, otherwise target is the bots name?
// Due to the original nature of this code, some of these routines assume the in channel case, others assume the /msg case.
// Also check the commands that can have a channel argument work the same in and out of channel.
enum chanserv_command_type
{
INFO_COMMAND = 0,
SAFE_COMMAND = 1,
NORMAL_COMMAND = 2,
DANGER_COMMAND = 3,
PASSWORD_COMMAND = 4
};
struct chanserv_command
{
enum chanserv_command_type type;
int access;
int arg_count;
int too_many; /* Check for too many args */
struct chanserv_output *(*func) (char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost);
char *command[5];
char *syntax;
char *summary;
};
static void show_output(char *source, char *target, struct chanserv_output *result, enum chanserv_invoke_type input_type);
struct chanserv_output *chanserv_show_help(char *cmd, int user_level);
struct chanserv_output *chanserv_asprintf(struct chanserv_output *output, const char *format, ...)
{
struct chanserv_output *result = NULL;
static char temp[BUFSIZ]; /* a temp buffer (8KB) */
va_list list;
int r;
va_start(list, format);
r = vsprintf(temp, format, list);
va_end(list);
if (r >= 0)
{
char *ptr;
ptr = malloc(r + 1);
if (ptr)
{
result = malloc(sizeof(struct chanserv_output));
if (result)
{
strncpy(ptr, temp, r); /* copy at most n */
ptr[r] = '\0'; /* ensure \0 at end */
result->output = ptr;
result->next = NULL;
if (output)
{
struct chanserv_output *next = output;
while (next->next)
next = next->next;
next->next = result;
result = output;
}
}
else
free(ptr);
}
}
if (result == NULL)
{
;// FIXME: Should bitch about lack of ram.
}
return result;
}
void chanserv_output_free(struct chanserv_output *output)
{
while (output)
{
struct chanserv_output *next = output->next;
free(output->output);
free(output);
output = next;
}
}
struct chanserv_output *chanserv_add(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = { 0 }, topic [STRING_LONG] = {0};
if (!args || !args[0])
return chanserv_asprintf(NULL, "Add what?");
/* Save topic since we're chopping args[0] off later. */
strncpy (topic, args[0], sizeof (topic));
/* Check to make sure the topic doesn't exist first. */
if (check_existing_url(source, topic, target) == 1)
{
return chanserv_asprintf(result, "%s \37%s\37\n",
EXISTING_ENTRY, topic);
}
/* Cut off the first argument (the topic) */
args++;
if ((db_argstostr (str, args, 0, ' ')) < 1)
return chanserv_asprintf(result, "What info is to be added for %s?", topic);
// Fix for some segmentation fault problems
// concerning topics consisting entirely of
// wildcard characters.
if (strspn(topic, "*?") == strlen(topic))
return chanserv_asprintf(NULL, "Sorry, but support for that topic has been removed.");
/* FIXME: If both things happen, result is overwritten with
* the second event, and the first truncation isn't displayed
*/
if (strlen(topic) > MAX_TOPIC_SIZE)
{
topic[MAX_TOPIC_SIZE] = '\0';
result = chanserv_asprintf(NULL, "Topic is over the limit, and has had characters truncated.");
}
if (strlen(str) > MAX_DATA_SIZE)
{
str[MAX_DATA_SIZE] = '\0';
result = chanserv_asprintf(NULL, "Data is over the limit, and has had characters truncated.");
}
strlwr(topic);
/* Don't allow the topic to be an rdb file name. */
if (*topic == '~')
return chanserv_asprintf(result, "Rdb files can only be called from the data of a topic, they cannot be used in the topic itself.");
if (LOG_ADD_DELETES)
db_log(ADD_DELETES, "[%s] %s!%s ADD %s %s\n", date(), source,
userhost, topic, str);
ADDITIONS++;
if ((strspn (topic, "ilc")) == 3 ||
(strspn (topic, "iln")) == 3)
{
db_log(URL2, "%s ([%s] %s!%s): %s\n", topic, date(),
source, userhost, str);
}
else
{
db_log(URL2, "%s %s\n", topic, str);
}
return chanserv_asprintf(result, "Okay.");
}
struct chanserv_output *chanserv_add_user(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char temp[1024] = { 0 };
long sn = 0;
if (!args || !args[0] || !args[1] || !args[2] || !args[3])
return result;
sn = atoi(args[2]);
if (sn > 10 || sn <= 0)
return result;
if (strlen(args[1]) < 7)
return result;
snprintf(temp, sizeof (temp), "I haven't used \2%cSETINFO\2 yet!", *CMDCHAR);
add_helper(args[0], mask_from_nick(args[1], target), sn, 0, temp, args[3], 0);
save_changes();
return chanserv_asprintf(NULL, "Added user: %s - level %d.", mask_from_nick(args[1], target), sn);
}
struct chanserv_output *chanserv_alarm(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char temp[1024] = { 0 };
time_t sn = 0, unixtime = 0;
long i = 0;
if (!args || !args[0] || !args[1] || (strlen(args[0]) < 2))
return chanserv_asprintf(NULL, "Syntax: <time type: \2d/h/m/s\2><time> <text to say>");
if (tolower(*args[0]) == 'd')
{
/* Days. */
sn = 86400;
args[0]++;
}
else if (tolower(*args[0]) == 'h')
{
/* Hours */
sn = 3600;
args[0]++;
}
else if (tolower(*args[0]) == 'm')
{
/* Minutes */
sn = 60;
args[0]++;
}
else if (tolower(*args[0]) == 's')
{
/* Seconds */
sn = 1;
args[0]++;
}
else
{
return chanserv_asprintf(NULL, "Syntax: <time type: \2d/h/m/s\2><time> <text to say>");
}
snprintf(temp, sizeof (temp), "%s/%ld",
DBTIMERS_PATH,
(atoi (args[0]) * sn) + time (NULL));
db_log(temp, "PRIVMSG %s :\2ALARMCLOCK\2 by %s!%s: %s", source, source, userhost, args[1]);
unixtime = atoi (args[0]) * sn;
if (unixtime > 86400)
result = chanserv_asprintf(NULL, "alarmclock set to go off in %d day%s, %02d:%02d.",
unixtime / 86400,
plural((unixtime / 86400)),
(unixtime / 3600) % 24,
(unixtime / 60) % 60);
else if (unixtime > 3600)
result = chanserv_asprintf(NULL, "alarmclock set to go off in %d hour%s, %d min%s.",
unixtime / 3600,
plural ((unixtime / 3600)),
(unixtime / 60) % 60,
plural (((unixtime / 60) % 60)));
else
result = chanserv_asprintf(NULL, "alarm clock set to go off in %d minute%s, %d sec%s.",
unixtime / 60,
unixtime / 60 == 1 ? "" : "s",
unixtime % 60,
unixtime % 60 == 1 ? "" : "s");
return result;
}
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_autotopic(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char topic [STRING_LONG] = {0};
if (!args || !args[0])
return result;
if (db_argstostr(topic, args, 0, ' ') < 1)
return result;
set_autotopic (source, target, topic);
return result;
}
#endif
//#ifndef WIN32
struct chanserv_output *chanserv_backup(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
char temp[1024] = { 0 };
int ret;
snprintf(temp, sizeof (temp), "/bin/cp -f %s %s_`date +%%F_%%R.bak`\n", URL2, URL2);
ret = system(temp);
return chanserv_asprintf(NULL, "Backed up database.");
}
//#endif
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_ban_list(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return show_banlist(source);
}
#endif
#ifdef ENABLE_MATH
struct chanserv_output *chanserv_calc(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return result;
if (strlen(args[0]) > 200)
args[0][200] = '\0';
return do_math(source, target, args[0]);
}
#endif
struct chanserv_output *chanserv_chan_info(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return result;
else
/* If args[0] is not a valid channel name, just use the current channel */
result = show_chaninfo (source, ((*args[0] == '#' || *args[0] == '&' || *args[0] == '+') ? args[0] : target), target);
return result;
}
struct chanserv_output *chanserv_chan_users(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
result = show_chanusers (source, target);
else
/* If args[0] is not a valid channel name, just use the current channel. */
result = show_chanusers (source, ((*args[0] == '#' || *args[0] == '&' || *args[0] == '+') ? args[0] : target));
return result;
}
struct chanserv_output *chanserv_char(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return result;
return chanserv_asprintf(NULL, "%c -> %d.", args[0][0], args[0][0]);
}
struct chanserv_output *chanserv_char_show(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "My command char is: %c.", *CMDCHAR);
}
struct chanserv_output *chanserv_cpu_show(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
getrusage(RUSAGE_SELF, &r_usage);
return chanserv_asprintf(NULL, "CPU usage: %ld.%06ld, System = %ld.%06ld.", r_usage.ru_utime.tv_sec, r_usage.ru_utime.tv_usec, r_usage.ru_stime.tv_sec, r_usage.ru_stime.tv_usec);
}
struct chanserv_output *chanserv_cycle(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
int i = 0;
/* Check for channel list parameter being specified. */
if (!args | !args[0])
{
S ("PART %s\n", target);
S ("JOIN %s\n", target);
}
else
{
result = chanserv_asprintf(NULL, "Cycling %s.", args[0]);
S("PART %s\n", args[0]);
S("JOIN %s\n", args[0]);
}
return result;
}
struct chanserv_output *chanserv_data_search(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return chanserv_asprintf(NULL, "What should I be %sing for?", cmd);
printf ("args[0] = %s\n", args[0]);
datasearch (source, args[0], target);
return result;
}
struct chanserv_output *chanserv_date(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "%s.", date());
}
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_delban(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return chanserv_asprintf(NULL, "Enter the user@host to purge!");
if (del_permban(source, args[0]) == 1)
S("MODE %s -b %s\n", target, args[0]);
else
result = chanserv_asprintf(NULL, "No such ban.");
return result;
}
#endif
struct chanserv_output *chanserv_delete(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return chanserv_asprintf(NULL, "%s what?", cmd);
if (strlen (args[0]) > MAX_TOPIC_SIZE)
args[0][MAX_TOPIC_SIZE] = '\0';
if (LOG_ADD_DELETES)
db_log (ADD_DELETES, "[%s] %s!%s DEL %s\n", date (), source, userhost, args[0]);
if (*args[0] == '~')
{ /* need level 2 to delete .rdb files */
if (invoked == MSG_INVOKE)
{
if (check_access (userhost, "#*", 0, source) >= 2)
delete_url (source, args[0], source);
}
else
{
if (check_access (userhost, target, 0, source) >= 2)
delete_url (source, args[0], target);
}
return result;
}
if (invoked == MSG_INVOKE)
delete_url (source, args[0], source);
else
delete_url (source, args[0], target);
return result;
}
struct chanserv_output *chanserv_deluser(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return chanserv_asprintf(NULL, "Enter the user@host to delete!");
delete_user_ram (source, args[0]);
return result;
}
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_deop(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0}, chan[STRING_LONG] = {0};
/* Make sure first arg, which should be target chan, is there. */
if (!args || !args[0])
return result;
strncpy (chan, args[0], sizeof (chan));
/* Chop of first arg, since we have a copy as chan. */
args++;
db_argstostr (str, args, 0, ' ');
if ((invoked == MSG_INVOKE) || (*chan == '#'))
{
if (check_access (userhost, chan, 0, source) >= 3)
{
if (str[0] == '\0')
return result;
S ("MODE %s -oooooo %s\n", chan, str);
}
}
else
{
if (str[0] == '\0')
S ("MODE %s -oooooo %s\n", target, chan);
else
S ("MODE %s -oooooo %s %s\n", target, chan, str);
}
return result;
}
struct chanserv_output *chanserv_devoice(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char chan [STRING_LONG] = {0}, str [STRING_LONG] = {0};
if (!args || !args[0])
return result;
strncpy (chan, args[0], sizeof (chan));
args++;
db_argstostr (str, args, 0, ' ');
if ((invoked == MSG_INVOKE) || (*chan == '#'))
{
if (check_access (userhost, chan, 0, source) >= 3)
{
if (str[0] == '\0')
return result;
S ("MODE %s -vvvvvv %s\n", chan, str);
}
}
else
{
if (str[0] == '\0')
S ("MODE %s -vvvvvvv %s\n", target, chan);
else
S ("MODE %s -vvvvvvv %s %s\n", target, chan, str);
}
return result;
}
#endif
struct chanserv_output *chanserv_die(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
long unixtime = 0;
if (!args || !args[0])
Snow("QUIT :K\2\2illed (%s (cause I say so!))\n", source);
else
{
if ((db_argstostr (str, args, 0, ' ')) < 1)
return result;
Snow("QUIT :K\2\2illed (%s (%s))\n", source, str);
}
db_sleep (1);
printf ("\n\nGood-bye! %s (c) Jason Hamilton\n\n", dbVersion);
uptime = time (NULL) - uptime;
printf("Time elapsed: %ld hour%s, %ld min%s\n\n",
uptime / 3600,
uptime / 3600 == 1 ? "" : "s",
(uptime / 60) % 60, (uptime / 60) % 60 == 1 ? "" : "s");
db_sleep (5);
exit (0);
return result;
}
struct chanserv_output *chanserv_display(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return result;
result = display_url(target, source, args[0]);
return result;
}
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_down(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
S ("MODE %s -o %s\n", target, source);
return result;
}
#endif
struct chanserv_output *chanserv_darkbot(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (Sleep_Toggle == 1)
return result;
if (cf (userhost, source, target))
return result;
return chanserv_asprintf(NULL, "%s reporting! My cmdchar is %c.", dbVersion, *CMDCHAR);
}
struct chanserv_output *chanserv_help(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
if (!args || !args[0])
{
result = chanserv_asprintf(result, "I can be triggered by various forms of speech, all which must be addressed to me, in one of the following formats: %s %s %s or even %s . In my database, you can find a topic by saying my nick, <topic> . eg; \37%s nuke\37 . To do a search on a word, or partial text, just type: search <text> or dsearch <text> , eg; \37search nuke\37.",
NICK_COMMA, COLON_NICK, BCOLON_NICK, Mynick, NICK_COMMA);
if (cf (userhost, source, target))
return result;
- result = chanserv_asprintf(result, "I can also be triggered with even more human formats: \37%s who is bill gates?\37 . You can also phrase it as a question: \37%s where is msie?\37 . For a list of commands use \37help commands\37 . For a list of setup parameters use \37help parameters\37 . For more info about me, visit http://www.freezedown.org/ .",
+ result = chanserv_asprintf(result, "I can also be triggered with even more human formats: \37%s who is bill gates?\37 . You can also phrase it as a question: \37%s where is msie?\37 . For a list of commands use \37help commands\37 . For a list of setup parameters use \37help parameters\37 . For more info about me, visit http://darkbot.sourceforge.net .",
NICK_COMMA, NICK_COMMA, NICK_COMMA);
return (result);
}
if ((db_argstostr (str, args, 0, ' ')) < 1)
return;
result = chanserv_show_help(str, check_access(userhost, (invoked == MSG_INVOKE) ? "#*" : target, 0, source));
return result;
}
struct chanserv_output *chanserv_idle(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
long unixtime = 0;
if (!args || !args[0])
return result;
if (strcasecmp (args[0], source) == 0)
return chanserv_asprintf(NULL, "Don't be lame.");
unixtime = return_useridle (target, args[0], 0);
if (unixtime == 0)
return chanserv_asprintf(NULL, "I do not see %s in %s.", args[0], target);
unixtime = time (NULL) - unixtime;
if (unixtime > 86400)
result = chanserv_asprintf(result, " %s has been idle %d day%s, %02d:%02d.",
args[0], unixtime / 86400,
(unixtime / 86400 == 1) ? "" : "s",
(unixtime / 3600) % 24, (unixtime / 60) % 60);
else if (unixtime > 3600)
result = chanserv_asprintf(result, "%s has been idle %d hour%s, %d min%s.",
args[0], unixtime / 3600,
unixtime / 3600 == 1 ? "" : "s",
(unixtime / 60) % 60, (unixtime / 60) % 60 == 1 ? "" : "s");
else
result = chanserv_asprintf(result, " %s has been idle %d minute%s, %d sec%s.",
args[0], unixtime / 60,
unixtime / 60 == 1 ? "" : "s", unixtime % 60, unixtime % 60 == 1 ? "" : "s");
return result;
}
struct chanserv_output *chanserv_ignore(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return chanserv_asprintf(NULL, "Ignore who?");
if ( add_ignore_user_ram(args[0]) > 0 )
result = chanserv_asprintf(result, "Ignoring %s.", args[0]);
else
result = chanserv_asprintf(result, "Unable to ignore %s.", args[0]);
return result;
}
struct chanserv_output *chanserv_info(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
info (source, (invoked == MSG_INVOKE) ? source : target);
return result;
}
struct chanserv_output *chanserv_info_2(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return show_info2((invoked == MSG_INVOKE) ? source : target, source, invoked);
}
struct chanserv_output *chanserv_info_size(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
struct stat statbuf;
if (stat (URL2, &statbuf) == 0)
result = chanserv_asprintf(NULL, "My database file is presently %ld byte%s in size.", statbuf.st_size, ((statbuf.st_size == 1) ? "" : "s"));
return result;
}
struct chanserv_output *chanserv_isop(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return result;
result = chanserv_asprintf(NULL, "%s is %san op in channel %s.", args[0], is_op(args[0], target) ? "" : "not ", target);
return result;
}
struct chanserv_output *chanserv_join(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
S ("JOIN %s\n", target);
else
{
S ("JOIN %s\n", args[0]);
result = chanserv_asprintf(NULL, "Joining %s.", args[0]);
}
return result;
}
struct chanserv_output *chanserv_joins_show(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "I have seen %d joins thus far.", JOINs);
}
struct chanserv_output *chanserv_jump(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char server [STRING_LONG] = {0}, str [STRING_LONG] = {0};
long sn = 0;
if (!args || !args[0])
return result;
strncpy (server, args[0], sizeof (server));
args++;
if ((db_argstostr (str, args, 0, ' ')) < 1)
sn = 6667;
else
sn = atoi(str);
S ("QUIT :Jumping to %s:%d\n", server, sn);
db_sleep (1);
strncpy (BS, server, sizeof (BS));
BP = sn;
prepare_bot ();
register_bot ();
return result;
}
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_kick(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char chan[STRING_LONG] = {0}, nick[STRING_LONG] = {0},
reason [STRING_LONG] = {0};
if (!args || !args[0])
return chanserv_asprintf(NULL, "Specify a nick/channel!");
if (invoked == MSG_INVOKE)
{
/* Copy channel variable and chuck it. */
strncpy (chan, args[0], sizeof (chan));
args++;
/* Make sure first parameter is a channel name. */
if ((*chan != '#') && (*chan != '&'))
return chanserv_asprintf (NULL, "You must specify a channel name first.");
if (check_access (userhost, chan, 0, source) >= 3)
{
if (!args[0])
return chanserv_asprintf(NULL, "You must specity a nickname to kick!");
strncpy (nick, args[0], sizeof (nick));
args++;
/* Remaining args are fed into reason. */
if ((db_argstostr (reason, args, 0, ' ')) < 1)
S ("KICK %s %s %s\n", chan, nick, DEFAULT_KICK);
else
S ("KICK %s %s :%s\n", chan, nick, reason);
return result;
}
}
else
{
if (*args[0] != '#' && *args[0] != '&')
{
strncpy (nick, args[0], sizeof (nick));
args++;
if (strcasecmp (nick, Mynick) == 0)
S ("KICK %s %s :hah! As *IF*\n", target, source);
if ((db_argstostr (reason, args, 0, ' ')) < 1)
S ("KICK %s %s :\2%s\2'ed: %s\n", target, nick, cmd, DEFAULT_KICK);
else
S ("KICK %s %s :\2%s\2'ed: %s\n", target, nick, cmd, reason);
}
else
{
if (!args[0] || !args[1])
return chanserv_asprintf(result, "You must specify a nickname to kick!");
strncpy (chan, args[0], sizeof chan);
args++;
strncpy (nick, args[0], sizeof nick);
args++;
if (strcasecmp (nick, Mynick) == 0)
S ("KICK %s %s :hah! As *IF*\n", target, nick);
if ((db_argstostr (reason, args, 0, ' ')) < 1)
S ("KICK %s %s :\2%s\2ed: %s\n", chan, nick, cmd, DEFAULT_KICK);
else
S ("KICK %s %s :\2%s\2ed: %s\n", chan, nick, cmd, reason);
}
}
return result;
}
#endif
struct chanserv_output *chanserv_language(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "I speak English.");
}
struct chanserv_output *chanserv_leave(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char chan [STRING_LONG] = {0},
reason [STRING_LONG] = {0};
if (!args || !args[0])
S ("PART %s\n", target);
else
{
strncpy (chan, args[0], sizeof chan);
args++;
/* Don't bother telling the channel we left about it. */
if ((strcasecmp (target, chan)) != 0)
result = chanserv_asprintf(result, "Leaving %s.", chan);
if ((db_argstostr (reason, args, 0, ' ')) < 1)
S ("PART %s :Requested!\n", chan);
else
S ("PART %s :%s\n", chan, reason);
}
return (result);
}
struct chanserv_output *chanserv_length(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
if (!args || !args[0])
return result;
if ((db_argstostr (str, args, 0, ' ')) == 0)
strcpy(str, args[0]);
return chanserv_asprintf(NULL, "It was %d characters long.", strlen (str));
}
struct chanserv_output *chanserv_level(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char *uh;
if (!args || !args[0])
return result;
uh = uh_from_nick(args[0], target);
if (uh)
result = chanserv_asprintf(result, "%s is level %d in channel %s.", args[0], check_access(uh, target, 0, args[0]), target);
return result;
}
struct chanserv_output *chanserv_location_show(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "There %s %d server%s in my server list. I am currently on server #%d.", (snr == 1) ? "is" : "are", snr, (snr == 1) ? "" : "s", spr);
}
struct chanserv_output *chanserv_login(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return result;
do_login (source, args[0]);
return result;
}
struct chanserv_output *chanserv_mask(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
int i = 0;
struct chanserv_output *result = NULL;
if(!args || !args[0])
return result;
return chanserv_asprintf(NULL, " %s",
(invoked == MSG_INVOKE) ? mask_from_nick(args[0], "#*") : mask_from_nick(args[0], target));
}
//#ifndef WIN32
struct chanserv_output *chanserv_memory(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
char temp[1024] = { 0 };
snprintf(temp, sizeof (temp), "ps u -p %d\n", getpid());
const char *ptr = run_program (temp);
if (ptr == NULL)
return chanserv_asprintf(NULL, "Unable to gather data for mem output.\n");
else
return chanserv_asprintf(NULL, "ps: %s", ptr);
}
//#endif
#ifdef ENABLE_METAR
struct chanserv_output *chanserv_metar(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if(!args || !args[0])
return chanserv_asprintf(NULL, "Metar what?");
result = web_post_query (cmd, source, userhost, target, args[0], strlen(args[0]));
return result;
}
#endif
struct chanserv_output *chanserv_nick(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
// If no nick was specified...
if(!args || !args[0])
return chanserv_asprintf(NULL, "Specify a nick!");
// If the nick specified contains illegal characters...
if(strspn(args[0], LEGAL_NICK_TEXT) != strlen(args[0]))
return chanserv_asprintf(NULL, "The nickname %s contains illegal characters.", args[0]);
strncpy(Mynick, args[0], sizeof (Mynick));
strncpy(s_Mynick, Mynick, sizeof (s_Mynick));
snprintf(NICK_COMMA, sizeof (NICK_COMMA), "%s,", Mynick);
snprintf(COLON_NICK, sizeof (COLON_NICK), "%s:", Mynick);
snprintf(BCOLON_NICK, sizeof (BCOLON_NICK), "%s\2:\2", Mynick);
// FIXME: This should be sent before the NICK attempt, and/or complain if the NICK doesn't work.
result = chanserv_asprintf(result, "Attempting to /nick %s.", Mynick);
S("NICK %s\n", Mynick);
return result;
}
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_op(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char nicks [STRING_LONG] = {0}, chan [STRING_LONG] = {0};
int ischan = 0;
if (!args[0])
return chanserv_asprintf (NULL, "You must specify a nickname/channel!.");
/* Check for channel name specified, set up args accordingly. */
if ((*args[0] == '#') || (*args[0] == '&'))
{
ischan = 1; /* channel specified */
strncpy (chan, args[0], sizeof chan);
args++;
}
if ((db_argstostr (nicks, args, 0, ' ')) < 1)
return chanserv_asprintf (NULL, "You must specify a nickname to op.");
if ((invoked == MSG_INVOKE) || (ischan == 1))
{
/* If MSG_INVOKE, make sure chan == 1. This seems weird, but
* we could have MSG_INVOKE without channel specified. */
if (ischan != 1)
return chanserv_asprintf (NULL, "You must specify a channel to deop people on.");
if (check_access (userhost, chan, 0, source) >= 3)
{
S ("MODE %s +oooooo %s\n", chan, nicks);
return result;
}
}
else
S ("MODE %s +oooooo %s\n", target, nicks);
return result;
}
#endif
struct chanserv_output *chanserv_os_show(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char temp[1024] = { 0 };
char *reply = NULL;
#ifdef WIN32
snprintf (temp, sizeof (temp), "cmd /c ver\n");
#else
snprintf (temp, sizeof (temp), "uname\n");
#endif
return chanserv_asprintf(NULL, "I am running %s.", run_program(temp));
}
struct chanserv_output *chanserv_password(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (args[0] == NULL || args[1] == NULL)
return result;
if (strlen(args[1]) > 25)
args[1][25] = '\0';
set_pass(source, userhost, args[0], args[1]);
return result;
}
struct chanserv_output *chanserv_performs(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
/* Set the default umodes */
S ("MODE %s %s\n", Mynick, DEFAULT_UMODE);
run_perform ();
return chanserv_asprintf(NULL, "Performs have been executed.");
}
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_perm_ban(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char reason [STRING_LONG] = {0}, host [STRING_LONG] = {0};
if (!args || !args[0])
return result = chanserv_asprintf(result, "Type !help permbans");
strncpy (host, args[0], sizeof host);
args++;
if ((db_argstostr (reason, args, 0, ' ')) < 1)
strncpy (reason, "Permbanned!", sizeof reason);
add_permban(host, 0, reason);
result = chanserv_asprintf(result, "Added in permban #%d, %s; reason: %s.",
PERMBAN_counter, host, reason);
save_permbans();
S("MODE %s +b %s\n", target, host);
/* FIXME: Scan for user in room and kick them with reason. */
return result;
}
struct chanserv_output *chanserv_perm_bans_list(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "There %s %d permban%s loaded into ram.", (PERMBAN_counter == 1) ? "is" : "are", PERMBAN_counter, (PERMBAN_counter == 1) ? "" : "s");
}
#endif
#ifdef ENABLE_CTCP
struct chanserv_output *chanserv_ping(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (cf(userhost, source, target))
return result;
if (cf(userhost, source, target))
return result;
if (args[0] != NULL)
{
if (strlen (args[0]) > 21)
args[0][21] = '\0';
S ("NOTICE %s :\1PING %s\n", source, args[0]);
}
return result;
}
#endif
struct chanserv_output *chanserv_ping2(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "PONG!");
}
struct chanserv_output *chanserv_queue_show(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "There is currently %d item%s in queue.", get_sendq_count(2), (get_sendq_count(2) == 1) ? "" : "s");
}
#ifdef ENABLE_QUIZ
struct chanserv_output *chanserv_quiz(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (quiz_halt == 0)
result = run_quiz_question (target);
return result;
}
#endif
#ifdef ENABLE_RANDQ
struct chanserv_output *chanserv_quote(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return do_randq(args[0], RANDQ_RAND, target, source);
}
struct chanserv_output *chanserv_random_quote(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
if (!args || !args[0])
return chanserv_asprintf (NULL, "You must specify a search string.");
// RANDQ_NORMAL
return do_randq(args[0], RANDQ_NORMAL, target, source);
}
struct chanserv_output *chanserv_random_quote_2(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
if (!args || !args[0])
return chanserv_asprintf (NULL, "You must specify a search string.");
// RANDQ_CASE
return do_randq(args[0], RANDQ_CASE, target, source);
}
#endif
#ifdef ENABLE_RANDOM
struct chanserv_output *chanserv_random_stuff(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
/* Fill argument buffer, if it's empty we return a message to
* the user asking for input. */
if (!args || !args[0])
return chanserv_asprintf(NULL, "What do you want to add?");
if ((db_argstostr (str, args, 0, ' ')) < 1)
return result;
if (invoked == MSG_INVOKE)
{
if (check_access (userhost, "#*", 0, source) >= RAND_LEVEL)
{
if ((db_argstostr (str, args, 0, ' ')) < 1)
return chanserv_asprintf(NULL, "What do you want to add?");
add_randomstuff(source, source, str);
}
}
else
add_randomstuff(source, target, str);
return result;
}
struct chanserv_output *chanserv_random_stuff_list(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "%d seconds left till randstuff.", Rand_Stuff);
}
#endif
struct chanserv_output *chanserv_raw(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
if (!args || !args[0])
return result;
if ((db_argstostr (str, args, 0, ' ')) < 1)
return result;
Snow("%s\n", str);
return result;
}
//#ifndef WIN32
struct chanserv_output *chanserv_rdb(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char temp[1024] = { 0 };
char str [STRING_LONG] = {0};
/* Check for arguments */
if (!args || !args[0])
{
snprintf(temp, sizeof (temp), "ls %s/*.rdb | wc\n", RDB_DIR);
result = chanserv_asprintf(result, "RDB: %s.", run_program(temp));
}
else
{
if ((db_argstostr (str, args, 0, ' ')) < 1)
return result;
if (strspn(str, SAFE_LIST) != strlen(str))
return chanserv_asprintf(NULL, "Rdb files are made up of letters and or numbers, no other text is accepted.");
snprintf(temp, sizeof (temp), "cat %s/%s.rdb | wc -l\n", RDB_DIR, str);
result = chanserv_asprintf(result, "%s", run_program(temp));
}
return result;
}
//#endif
struct chanserv_output *chanserv_repeat(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
long sn2 = 0, sn = 0;
char str [STRING_LONG] = {0};
if (!args || !args[0] || !args[1] || !args[2])
return result;
sn = atoi (args[0]);
sn2 = atoi (args[1]);
if ((db_argstostr (str, args, 2, ' ')) < 1)
return result;
while (sn > 0)
{
S ("%s\n", str);
db_sleep (sn2);
sn--;
}
return result;
}
struct chanserv_output *chanserv_replace(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char topic [STRING_LONG] = {0}, str [STRING_LONG] = {0};
if (!args || !args[0])
return chanserv_asprintf(NULL, "Replace what?");
if (strlen(args[0]) > MAX_TOPIC_SIZE)
args[0][MAX_TOPIC_SIZE] = '\0';
/* Copy topic, and traverse args for data to be replaced. */
strncpy (topic, args[0], sizeof topic);
args++;
/* Make sure there's information to be replaced. */
if ((db_argstostr (str, args, 0, ' ')) < 1)
return chanserv_asprintf(NULL, "What info should replace %s?",
topic);
/* Don't let str go over MAX_DATA_SIZE characters. */
if (strlen(str) > MAX_DATA_SIZE)
str[MAX_DATA_SIZE] = '\0';
strlwr(topic);
if (check_existing_url(source, topic, target) != 1)
return chanserv_asprintf(NULL, "%s \37%s\37", NO_ENTRY, topic);
/* Replace the data. */
delete_url (source, topic, target);
if (LOG_ADD_DELETES)
db_log (ADD_DELETES, "[%s] %s!%s REPLACE %s %s\n", date (), source, userhost, topic, str);
ADDITIONS++;
db_log (URL2, "%s %s\n", topic, str);
return chanserv_asprintf(NULL, "%s has been updated.", topic);
}
struct chanserv_output *chanserv_reserved_1(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return result;
call_reserved_1(source, target, args[0]);
return result;
}
struct chanserv_output *chanserv_reserved_2(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return result;
call_reserved_2(source, target, args[0]);
return result;
}
struct chanserv_output *chanserv_restart(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char temp[1024] = { 0 };
int ret;
S("QUIT :Restarting %s ...\n", dbVersion);
db_sleep(2);
snprintf(temp, sizeof (temp), "%s", DARKBOT_BIN);
ret = system(temp);
db_sleep(1);
exit(0);
return result;
}
struct chanserv_output *chanserv_search(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
{
if (strcasecmp(cmd, "FIND") == 0)
result = chanserv_asprintf(NULL, "%s?", TRY_FIND);
else
result = chanserv_asprintf(NULL, "What should I be %sing for?", cmd);
return result;
}
find_url(source, args[0], target);
return result;
}
struct chanserv_output *chanserv_seen(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
{
count_seen(source, target);
return result;
}
if (return_useridle (target, args[0], 1) == 1)
return chanserv_asprintf(NULL, "%s is right here in the channel!", args[0]);
result = show_seen(args[0], source, target);
return result;
}
struct chanserv_output *chanserv_set(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
struct setup_parameter *param = NULL;
if (!args || !args[0])
return result;
param = set_parameter(args[0]);
if (param)
{
switch (param->type)
{
case ST_BOOLEAN :
{
bool *variable = param->value;
result = chanserv_asprintf(result, "Setting %s = %s", param->summary, (*variable) ? "true" : "false");
break;
}
case ST_INTEGER :
{
long *variable = param->value;
result = chanserv_asprintf(result, "Setting %s = %ld", param->summary, *variable);
break;
}
case ST_STRING :
{
char *variable = param->value;
result = chanserv_asprintf(result, "Setting %s = %s", param->summary, variable);
break;
}
}
save_setup();
}
else
result = chanserv_asprintf(result, "Unknown parameter.");
return result;
}
struct chanserv_output *chanserv_setinfo(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
if (!args)
return chanserv_asprintf (NULL, "My %s variables are: ^ nick, %% number of joins, & Channel, $ user@host. Example: !setinfo ^ has joined & %% times (also, if you make the first char of your %s a \"+\", the %s will be shown as an ACTION).", cmd, cmd, cmd);
if ((db_argstostr (str, args, 0, ' ')) < 1)
return;
update_setinfo (userhost, str, source);
return (result);
}
struct chanserv_output *chanserv_sleep(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
Sleep_Toggle = 1;
/* Copy arguments to buffer, if there is one convert to long
* and use it as the sleep time in seconds. */
if ((db_argstostr (str, args, 0, '\0')) < 1)
Sleep_Time = SLEEP_TIME;
else if ((Sleep_Time = strtol (str, (char **) NULL, 10)) < 1)
Sleep_Time = SLEEP_TIME;
strncpy (sleep_chan, target, sizeof (sleep_chan));
/* If the user has specified a custom length of time to sleep for, send
* a notice reminding the user how long the bot will be asleep, in a
* more readible format.
*/
if (Sleep_Time != SLEEP_TIME)
{
if (Sleep_Time > 86400)
result = chanserv_asprintf(result, "Sleeping for %ld day%s, %02ld:%02ld.",
Sleep_Time / 86400,
(Sleep_Time / 86400 == 1) ? "" : "s",
(Sleep_Time / 3600) % 24,
(Sleep_Time / 60) % 60);
else if (Sleep_Time > 3600)
result = chanserv_asprintf(result, "Sleeping for %ld hour%s, %ld min%s.",
Sleep_Time / 3600,
Sleep_Time / 3600 == 1 ? "" : "s",
(Sleep_Time / 60) % 60,
(Sleep_Time/ 60) % 60 == 1 ? "" : "s");
else
result = chanserv_asprintf(result, "Sleeping for %ld minute%s, %ld sec%s.",
Sleep_Time / 60,
Sleep_Time / 60 == 1 ? "" : "s",
Sleep_Time % 60,
Sleep_Time % 60 == 1 ? "" : "s");
}
else
S ("PRIVMSG %s :%s\n", target, GOSLEEP_ACTION);
return result;
}
#ifdef ENABLE_STATS
struct chanserv_output *chanserv_stats(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return result = chanserv_asprintf (NULL, "Syntax: %s <nick>", cmd);
result = get_stats(target, args[0]);
return result;
}
#endif
#ifdef ENABLE_TAF
struct chanserv_output *chanserv_taf(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if(!args || !args[0])
return chanserv_asprintf(NULL, "Taf what?");
result = web_post_query(cmd, source, userhost, target, args[0], strlen(args[0]));
return result;
}
#endif
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_teaseop(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return chanserv_asprintf(NULL, "Specify a nick!");
if (strcasecmp (args[0], Mynick) == 0)
result = chanserv_asprintf(result, "How about I not do that?");
else
S ("MODE %s +o-o+o-o+o-o %s %s %s %s %s %s\n", target, args[0], args[0], args[0], args[0], args[0], args[0]);
return result;
}
#endif
struct chanserv_output *chanserv_tell(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
if (!args || !args[0])
return chanserv_asprintf(NULL, "Tell who?");
if (!args[1])
return chanserv_asprintf(NULL, "What do you want me to tell %s?", args[0]);
if (strcasecmp (args[1], Mynick) == 0)
return result; /* don't bother telling myself about stuff */
if (strcasecmp (args[1], "ABOUT") == 0)
{
if ((db_argstostr (str, args, 2, '+')) < 1)
return chanserv_asprintf(NULL, "Tell %s about what?", args[0]);
strlwr(str);
if (invoked == MSG_INVOKE)
result = show_url (source, get_multiword_topic (str), args[0], 1, 0, userhost, 1);
else
result = show_url (args[0], get_multiword_topic (str), target, 1, 0, userhost, 1);
}
else
{
if ((db_argstostr (str, args, 1, '+')) < 1)
return chanserv_asprintf (NULL, "Tell %s about what?", args[0]);
strlwr(str);
if (invoked == MSG_INVOKE)
result = show_url (source, get_multiword_topic (str), args[0], 1, 0, userhost, 1);
else
result = show_url (args[0], get_multiword_topic (str), target, 1, 0, userhost, 1);
}
return result;
}
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_topic(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
if ((db_argstostr (str, args, 0, ' ')) < 1)
return chanserv_asprintf (NULL, "What do you want the topic changed to?");
else
S ("TOPIC %s :%s\n", target, str);
return result;
}
#endif
struct chanserv_output *chanserv_unignore(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return chanserv_asprintf(NULL, "Unignore who?");
if ( delete_ignore_user_ram (args[0]) > 0 )
result = chanserv_asprintf(result, "Unignoring %s.", args[0]);
else
result = chanserv_asprintf(result, "Unable to unignore %s. :(", args[0]);
return result;
}
struct chanserv_output *chanserv_unixtime(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
time_t unixtime = 0, input_t = 0, cur_t = 0;
char *things = NULL;
int errno;
/* Check if anything was given as input and only do stuff
* (in this function, anyway) if so. */
if (!args || !args[0])
return result;
/* Make sure current time is available while acquiring it. */
if ((cur_t = time (NULL)) < 0)
{
result = chanserv_asprintf (result, "Unable to produce results because current system time is unavailable.");
return (result);
}
/* Convert input value to time_t. We check if the return value is
* 0 here, but our main concern is if things is NULL, because that
* would mean the function converted a string value "0", instead
* of returning a failing code. Set errno to 0 first as for a
* precautionary measure.
*/
errno = 0;
if ((input_t = (time_t) strtol (args[0], &things, 10)) == 0)
{
if (things == NULL)
{
result = chanserv_asprintf (result, "%s (things = %s)", strerror (errno), things);
return (result);
}
/* things was not NULL, this is "0" converted to long.
* So we continue as if nothing happened. */
}
/* Check for out of range values, tell the user which range
* was exceeded, perhaps for debugging purposes. */
if (errno == ERANGE)
{
result = chanserv_asprintf (result, "Your implementation does not support numeric ranges beyond %ld for this function.",
input_t);
return (result);
}
unixtime = input_t - cur_t;
if (unixtime > 86400)
result = chanserv_asprintf(result, "%d day%s, %02d:%02d.",
unixtime / 86400,
plural (unixtime / 86400),
(unixtime / 3600) % 24,
(unixtime / 60) % 60);
else if (unixtime > 3600)
result = chanserv_asprintf(result, "%d hour%s, %d min%s.",
unixtime / 3600,
plural(unixtime / 3600),
(unixtime / 60) % 60,
plural(unixtime / 60));
else
result = chanserv_asprintf(result, "%d minute%s, %d sec%s.",
unixtime / 60,
plural(unixtime / 60),
unixtime % 60,
plural(unixtime % 60));
return result;
}
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_up(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
S ("MODE %s +o %s\n", target, source);
return result;
}
#endif
//#ifndef WIN32
struct chanserv_output *chanserv_uptime(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
char temp[1024] = { 0 };
snprintf(temp, sizeof (temp), "uptime\n");
return chanserv_asprintf(NULL, "Uptime: %s.", run_program(temp));
}
//#endif
struct chanserv_output *chanserv_user_list(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
int i = 0;
if (!args)
{
result = show_helper_list(result, source, 0);
}
else
{
int level = 0;
for (i = 0; args[i]; i++)
result = show_helper_list(result, source, atoi (args[i]));
}
return result;
}
#ifdef ENABLE_STATUS
struct chanserv_output *chanserv_users_list(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
S ("LUSERS\n");
return result;
}
#endif
struct chanserv_output *chanserv_variables(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
return chanserv_asprintf(NULL, "Data variables are: N~ (Nick), C~ (Chan), T~ (Time/date) B~ (Botnick), Q~ (Question asked), R~ (random nick), !~ (command char), S~ (current Server), P~ (current port) V~ (botVer), W~ (db WWW site), H~ (u@h), t~ (unixtime), BAN (sets a ban), TEMPBAN (bans for 60 sec).");
}
#ifdef ENABLE_CTCP
struct chanserv_output *chanserv_version(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (cf (userhost, source, target))
return result;
if (cf (userhost, source, target))
return result;
- return chanserv_asprintf(NULL, "\1VERSION Hi, I'm a Darkbot. Download me from http://www.darkbot.org\1.");
+ return chanserv_asprintf(NULL, "\1VERSION Hi, I'm a Darkbot. Download me from http://darkbot.sourceforge.net\1.");
}
#endif
#ifdef ENABLE_CHANNEL
struct chanserv_output *chanserv_voice(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char nicks [STRING_LONG] = {0}, chan [STRING_LONG] = {0},
str [STRING_LONG] = {0};
int ischan = 0;
if (!args[0])
return result;
db_argstostr (str, args, 0, ' ');
/* Check for channel name specified, set up args accordingly. */
if ((*args[0] == '#') || (*args[0] == '&'))
{
ischan = 1; /* channel specified */
strncpy (chan, args[0], sizeof chan);
args++;
}
if ((db_argstostr (nicks, args, 0, ' ')) < 1)
return chanserv_asprintf (NULL, "You must specify a nickname to voice.");
if ((invoked == MSG_INVOKE) || (ischan == 1))
{
/* If MSG_INVOke, make sure chan ==1. This seems weird,
* but we could have MSG_INVOKE without a channel given,
* and this is an error. */
if (ischan != 1)
return chanserv_asprintf (NULL, "You must specify a channel to give voice on.");
if (check_access (userhost, chan, 0, source) >= 3)
{
S ("MODE %s +vvvvvv %s\n", chan, nicks);
return result;
}
}
else
S ("MODE %s +vvvvvv %s\n", target, nicks);
return result;
}
#endif
struct chanserv_output *chanserv_wakeup(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (Sleep_Toggle == 0)
return result;
Sleep_Toggle = 0;
AIL4 = 0;
S ("PRIVMSG %s :%s\n", target, WAKEUP_ACTION);
if (strcasecmp (sleep_chan, target) != 0)
S ("PRIVMSG %s :%s\n", sleep_chan, WAKEUP_ACTION);
return result;
}
#ifdef ENABLE_WEATHER
struct chanserv_output *chanserv_weather(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if (!args || !args[0])
return chanserv_asprintf(NULL, "Show weather from where?");
result = web_post_query(cmd, source, userhost, target, args[0], strlen(args[0]));
return result;
}
#endif
#ifdef ENABLE_WEBSEARCH
struct chanserv_output *chanserv_websearch(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
if(!args || !args[0])
return chanserv_asprintf(NULL, "Web search for what?");
result = web_post_query(cmd, source, userhost, target, args[0], strlen(args[0]));
return result;
}
#endif
struct chanserv_output *chanserv_where(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
char *ptr3 = NULL;
if (!args || !args[0])
return chanserv_asprintf(NULL, "You were asking?");
if (args[1] == NULL)
return result;
strlwr (args[1]);
ptr3 = strchr (args[1], '?');
if (ptr3 != NULL)
memmove (ptr3, ptr3 + 1, strlen (ptr3 + 1) + 1);
ptr3 = strchr (args[1], '!');
if (ptr3 != NULL)
memmove (ptr3, ptr3 + 1, strlen (ptr3 + 1) + 1);
if (strcasecmp (args[1], "A") == 0 || strcasecmp (args[1], "AN") == 0)
{
if ((db_argstostr (str, args, 2, ' ')) < 1)
return chanserv_asprintf(NULL, "%s %s %s? Mind rephrasing that? (Type %cHELP for syntax hints).", cmd, args[0], args[1], *CMDCHAR);
result = show_url (source, get_multiword_topic (str), (invoked == MSG_INVOKE) ? source : target, 1, 0, userhost, 0);
}
else
result = show_url (source, get_multiword_topic (args[1]), (invoked == MSG_INVOKE) ? source : target, 1, 0, userhost, 0);
return result;
}
struct chanserv_output *chanserv_whisper(char *source, char *target, char *cmd, char **args, enum chanserv_invoke_type invoked, char *userhost)
{
struct chanserv_output *result = NULL;
char str [STRING_LONG] = {0};
if (!args || !args[0])
return chanserv_asprintf(NULL, "Whisper to who?");
if (args[1] == NULL)
return chanserv_asprintf(NULL, "What do you want me to whisper to %s?", args[0]);
if (strcasecmp (args[1], Mynick) == 0)
return result; /* don't bother telling myself about stuff */
if (strcasecmp (args[1], "ABOUT") == 0)
{
if ((db_argstostr (str, args, 2, ' ')) < 1)
return chanserv_asprintf(NULL, "Whisper to %s about what?", args[0]);
strlwr(str);
result = show_url(source, get_multiword_topic(str), args[0], 1, 0, userhost, 1);
}
else
{
strlwr (args[1]);
result = show_url(source, get_multiword_topic(args[1]), args[0], 1, 0, userhost, 1);
}
return result;
}
/* The help system uses the first alias for each command for the list of commands.
* So make the first alias the most meaningful, and keep the list sorted by that first alias.
*/
struct chanserv_command chanserv_commands[] =
{
{NORMAL_COMMAND, ADD_LEVEL, 1, 0, chanserv_add, {"ADD", "REMEMBER", "SAVE", "STORE", NULL}, "<topic> <text>", "Add a topic and it's text."},
{PASSWORD_COMMAND, 3, 4, 0, chanserv_add_user, {"ADDUSER", NULL, NULL, NULL, NULL}, "<#channel|#*> <user@host> <level> [password]", "Add a user to the access list."},
{SAFE_COMMAND, 2, 2, 0, chanserv_alarm, {"ALARM", "ALARMCLOCK", NULL, NULL, NULL}, "<time type: d/h/m><time> <text to say>", "Set some text to be said by the bot at a later time."},
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 3, 1, 0, chanserv_autotopic, {"AUTOTOPIC", NULL, NULL, NULL, NULL}, "<channel topic>", "Refreshes the channel topic every thirty minutes (set to \"0\" to turn off)."},
#endif
//#ifndef WIN32
{DANGER_COMMAND, 3, 0, 0, chanserv_backup, {"BACKUP", NULL, NULL, NULL, NULL}, NULL, "Create a backup of the database."},
//#endif
#ifdef ENABLE_CHANNEL
{INFO_COMMAND, 1, 0, 0, chanserv_ban_list, {"BANLIST", NULL, NULL, NULL, NULL}, NULL, "Displays permanent bans."},
#endif
#ifdef ENABLE_MATH
{INFO_COMMAND, 0, 1, 0, chanserv_calc, {"CALC", "MATH", NULL, NULL, NULL}, "<expression>", "Very basic calculator."},
#endif
{INFO_COMMAND, 0, 1, 0, chanserv_chan_info, {"CHANINFO", NULL, NULL, NULL, NULL}, "<#channel>", "Displays number of users in channel and in ram."},
{INFO_COMMAND, 0, 1, 0, chanserv_chan_users, {"CHANUSERS", NULL, NULL, NULL, NULL}, "<#channel>", "Displays names of users in channel."},
{INFO_COMMAND, 0, 1, 0, chanserv_char, {"CHAR", NULL, NULL, NULL, NULL}, "<character>", "Show the ascii code of the character."},
{INFO_COMMAND, 0, 0, 1, chanserv_char_show, {"CMDCHAR?", NULL, NULL, NULL, NULL}, NULL, "Show command character."},
{INFO_COMMAND, 0, 0, 1, chanserv_cpu_show, {"CPU?", NULL, NULL, NULL, NULL}, NULL, "Show the cpu usage of the bot."},
{DANGER_COMMAND, 2, 0, 0, chanserv_cycle, {"CYCLE", "CYC", NULL, NULL, NULL}, "[#channel]", "Leave and rejoin the channel."},
{INFO_COMMAND, 0, 1, 0, chanserv_data_search, {"DATASEARCH", "DSEARCH", "DFIND", NULL, NULL}, "<topic>", "Search in the replies."},
{INFO_COMMAND, 0, 0, 0, chanserv_date, {"DATE", "TIME", NULL, NULL, NULL}, NULL, "Show the current date and time."},
{DANGER_COMMAND, 0, 1, 0, chanserv_reserved_2, {RESERVED2, NULL, NULL, NULL, NULL}, "<>", ""},
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 3, 1, 0, chanserv_delban, {"DELBAN", NULL, NULL, NULL, NULL}, "<user@host>", "Delete a user from the permanent ban list."},
#endif
{NORMAL_COMMAND, DEL_LEVEL, 1, 0, chanserv_delete, {"DELETE", "DEL", "REMOVE", "FORGET", NULL}, "<topic>", "Delete a topic."},
{DANGER_COMMAND, 3, 1, 0, chanserv_deluser, {"DELUSER", NULL, NULL, NULL, NULL}, "<user@host>", "Delete a user from the access list."},
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 3, 1, 0, chanserv_deop, {"DEOP", NULL, NULL, NULL, NULL}, "[#channel] <nicks>", "Remove channel operator status from users."},
{NORMAL_COMMAND, 3, 1, 0, chanserv_devoice, {"DEVOICE", "DV", "DEV", "DVOICE", NULL}, "[#channel] <nicks>", "Remove channel voice status from users."},
#endif
{DANGER_COMMAND, 3, 0, 0, chanserv_die, {"DIE", "QUIT", NULL, NULL, NULL}, NULL, "Stop bot from running."},
{INFO_COMMAND, 0, 1, 0, chanserv_display, {"DISPLAY", NULL, NULL, NULL, NULL}, "<topic>", "Display the text for a topic."},
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 2, 0, 0, chanserv_down, {"DOWN", NULL, NULL, NULL, NULL}, NULL, "Remove channel operator status from yourself."},
#endif
{INFO_COMMAND, 0, 0, 0, chanserv_darkbot, {"\2\2DARKBOT", NULL, NULL, NULL, NULL}, NULL, ""},
{DANGER_COMMAND, 0, 1, 0, chanserv_reserved_1, {RESERVED1, NULL, NULL, NULL, NULL}, "<>", ""},
{INFO_COMMAND, 0, 0, 0, chanserv_help, {"HELP", NULL, NULL, NULL, NULL}, "[command]", "Show some help text to the user."},
{INFO_COMMAND, 0, 1, 0, chanserv_idle, {"IDLE", NULL, NULL, NULL, NULL}, "<nick>", "Shows how long the user has been idle."},
{DANGER_COMMAND, 1, 1, 0, chanserv_ignore, {"IGNORE", NULL, NULL, NULL, NULL}, "<nick>", "Get bot to ignore a user."},
{INFO_COMMAND, 0, 0, 1, chanserv_info, {"INFO", NULL, NULL, NULL, NULL}, NULL, "Shows some information about bot and it's activity."},
{INFO_COMMAND, 0, 0, 1, chanserv_info_2, {"INFO2", NULL, NULL, NULL, NULL}, NULL, "Shows when the bot was compiled, and lines processed since startup."},
{INFO_COMMAND, 2, 0, 1, chanserv_info_size, {"INFOSIZE", "DBSIZE", NULL, NULL, NULL}, NULL, "Show size of the database."},
{INFO_COMMAND, 0, 1, 0, chanserv_isop, {"ISOP", NULL, NULL, NULL, NULL}, "<nick>", "Is user a channel op?"},
{DANGER_COMMAND, 2, 1, 0, chanserv_join, {"JOIN", "J", NULL, NULL, NULL}, "<#channel>", "Get bot to join a channel."},
{INFO_COMMAND, 0, 0, 1, chanserv_joins_show, {"JOINS?", NULL, NULL, NULL, NULL}, NULL, "Shows the number of user joins bot has seen in this channel since startup."},
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 3, 1, 0, chanserv_kick, {"KICK", "WHACK", "K", "NAIL", NULL}, "[#channel] <nick> [reason]", "Kick a user off the channel."},
#endif
{INFO_COMMAND, 0, 0, 0, chanserv_language, {"LANGUAGE", "LANG", NULL, NULL, NULL}, NULL, "Shows the language that bot is currently speaking."},
{DANGER_COMMAND, 2, 0, 0, chanserv_leave, {"LEAVE", "PART", "L", "P", NULL}, "[#channel]", "Get bot to leave the channel."},
{INFO_COMMAND, 0, 1, 0, chanserv_length, {"LENGTH", NULL, NULL, NULL, NULL}, "<text>", "Show the length of the text."},
{INFO_COMMAND, 0, 1, 0, chanserv_level, {"LEVEL", NULL, NULL, NULL, NULL}, "<nick>", "Show users level."},
{INFO_COMMAND, 0, 0, 0, chanserv_location_show, {"LOCATION?", NULL, NULL, NULL, NULL}, NULL, "Shows what servers are available and in use."},
{PASSWORD_COMMAND, 0, 1, 0, chanserv_login, {"LOGIN", NULL, NULL, NULL, NULL}, "<password>", "Gives you access to high level bot commands if you are on the access list."},
#ifdef ENABLE_STATUS
{INFO_COMMAND, 1, 0, 0, chanserv_users_list, {"LUSERS", NULL, NULL, NULL, NULL}, NULL, ""},
#endif
{INFO_COMMAND, 0, 1, 0, chanserv_mask, {"MASK", NULL, NULL, NULL, NULL}, "<nick>", "Show the users user@host mask."},
//#ifndef WIN32
{INFO_COMMAND, 3, 0, 1, chanserv_memory, {"MEM", "RAM", NULL, NULL, NULL}, NULL, "Shows some memory usage and process statistics."},
//#endif
#ifdef ENABLE_METAR
{NORMAL_COMMAND, 0, 1, 0, chanserv_metar, {"METAR", NULL, NULL, NULL, NULL}, "<city or code>", "Get raw METAR weather data."},
#endif
{DANGER_COMMAND, 3, 1, 0, chanserv_nick, {"NICK", "N", NULL, NULL, NULL}, "<newnick>", "Change bot's nickname, but not the default."},
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 3, 1, 0, chanserv_op, {"OP", NULL, NULL, NULL, NULL}, "[#channel] <nicks>", "Add channel operator status to users."},
#endif
{INFO_COMMAND, 0, 0, 1, chanserv_os_show, {"OS", NULL, NULL, NULL, NULL}, NULL, "Show the operating system that bot is running on."},
{PASSWORD_COMMAND, 0, 2, 0, chanserv_password, {"PASSWORD", "PASS", "PASSWD", NULL, NULL}, "<old password> <new password>", "Change your bot access list password."},
{DANGER_COMMAND, 3, 0, 0, chanserv_performs, {"PERFORMS", NULL, NULL, NULL, NULL}, NULL, "Perform the tasks in the perform.ini startup script."},
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 3, 1, 0, chanserv_perm_ban, {"PERMBAN", "SHITLIST", NULL, NULL, NULL}, "<user@host> [reason]", "Adds a user to the permanent ban list."},
{INFO_COMMAND, 0, 0, 0, chanserv_perm_bans_list, {"PERMBANS?", NULL, NULL, NULL, NULL}, NULL, "Shows how many permanent bans there are."},
#endif
#ifdef ENABLE_CTCP
{INFO_COMMAND, 0, 1, 0, chanserv_ping, {"\1PING", NULL, NULL, NULL, NULL}, "<>", ""},
#endif
{INFO_COMMAND, 0, 0, 0, chanserv_ping2, {"PING", NULL, NULL, NULL, NULL}, NULL, "Replies with \"PONG\" to see how lagged the bot is.."},
{INFO_COMMAND, 0, 0, 0, chanserv_queue_show, {"SENDQ?", "QUE?", NULL, NULL, NULL}, NULL, "Shows how many items are ready to be displayed."},
#ifdef ENABLE_QUIZ
{SAFE_COMMAND, 0, 0, 0, chanserv_quiz, {"QUIZ", NULL, NULL, NULL, NULL}, NULL, ""},
#endif
#ifdef ENABLE_RANDQ
{NORMAL_COMMAND, 0, 1, 0, chanserv_quote, {"QUOTE", NULL, NULL, NULL, NULL}, "[text]", "Shows a random quote."},
{NORMAL_COMMAND, 0, 1, 0, chanserv_random_quote, {"RANDQUOTE", "RANDQ", NULL, NULL, NULL}, "[text]", "Shows a random quote."},
{NORMAL_COMMAND, 0, 1, 0, chanserv_random_quote_2, {"RANDQUOTE2", "RANDQ2", NULL, NULL, NULL}, "[text]", "Shows a random quote."},
#endif
#ifdef ENABLE_RANDOM
{NORMAL_COMMAND, RAND_LEVEL, 1, 0, chanserv_random_stuff, {"RANDOMSTUFF", "RANDSTUFF", "RS", NULL, NULL}, "<text>", "Add random stuff to say."},
{INFO_COMMAND, 0, 0, 0, chanserv_random_stuff_list, {"RANDOMSTUFF?", "RANDSTUFF?", NULL, NULL, NULL}, NULL, "Shows time until next random thing is said."},
#endif
{DANGER_COMMAND, 3, 1, 0, chanserv_raw, {"RAW", NULL, NULL, NULL, NULL}, "<raw data>", "Get bot to send raw IRC data."},
//#ifndef WIN32
{INFO_COMMAND, 0, 0, 0, chanserv_rdb, {"RDB", NULL, NULL, NULL, NULL}, "[topic]", "Display information about the random databases."},
//#endif
{DANGER_COMMAND, 3, 3, 0, chanserv_repeat, {"REPEAT", "TIMER", NULL, NULL, NULL}, "<number> <delay> <raw data>", "Get bot to send raw IRC data a number of times."},
{NORMAL_COMMAND, 1, 1, 0, chanserv_replace, {"REPLACE", NULL, NULL, NULL, NULL}, "<topic> <text>", "Replace the text of a topic."},
{DANGER_COMMAND, 3, 0, 0, chanserv_restart, {"RESTART", "REHASH", NULL, NULL, NULL}, NULL, "Restart the bot."},
{INFO_COMMAND, 0, 1, 0, chanserv_search, {"SEARCH", "LOOK", "FIND", NULL, NULL}, "<text>", "Search in the topics."},
{INFO_COMMAND, 0, 1, 0, chanserv_seen, {"SEEN", NULL, NULL, NULL, NULL}, "<nick>", "Show the last time a user was seen."},
{DANGER_COMMAND, 3, 1, 0, chanserv_jump, {"SERVER", "JUMP", NULL, NULL, NULL}, "<server> [port]", "Switch bot to a different server."},
{DANGER_COMMAND, 3, 1, 0, chanserv_set, {"SET", NULL, NULL, NULL, NULL}, "<parameter>[=<new value>]", "Set or show the value of a setup.ini parameter. Usually requires a restart."},
{DANGER_COMMAND, 1, 1, 0, chanserv_setinfo, {"SETINFO", NULL, NULL, NULL, NULL}, "<new user greeting|0>", "Set your greeting from the bot when you join a channel."},
{SAFE_COMMAND, SLEEP_LEVEL, 1, 1, chanserv_sleep, {"SLEEP", "HUSH", NULL, NULL, NULL}, "[period]", "Deactivate bot for a period."},
#ifdef ENABLE_STATS
{INFO_COMMAND, 0, 0, 0, chanserv_stats, {"STATS", NULL, NULL, NULL, NULL}, "[nick]", "Shows statistics about questions answered."},
#endif
#ifdef ENABLE_TAF
{NORMAL_COMMAND, 0, 1, 0, chanserv_taf, {"TAF", NULL, NULL, NULL, NULL}, "<city or code>", "Get raw TAF weather data."},
#endif
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 2, 1, 0, chanserv_teaseop, {"TEASEOP", "TO", NULL, NULL, NULL}, "<nick>", "Tease a user with channel operator status."},
#endif
{INFO_COMMAND, 0, 2, 0, chanserv_tell, {"TELL", NULL, NULL, NULL, NULL}, "<nick> [ABOUT] <topic>", "Get bot to recall a topic to a user."},
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 2, 0, 0, chanserv_topic, {"TOPIC", "T", NULL, NULL, NULL}, "<channel topic>", "Change the channels topic."},
#endif
{DANGER_COMMAND, 1, 1, 0, chanserv_unignore, {"UNIGNORE", NULL, NULL, NULL, NULL}, "<nick>", "Get bot to stop ignoring a user."},
{INFO_COMMAND, 0, 1, 0, chanserv_unixtime, {"UNIXTIME", NULL, NULL, NULL, NULL}, "<time>", "Shows unixtime."},
#ifdef ENABLE_CHANNEL
{DANGER_COMMAND, 2, 0, 0, chanserv_up, {"UP", NULL, NULL, NULL, NULL}, NULL, "Add channel operator status to yourself."},
#endif
//#ifndef WIN32
{INFO_COMMAND, 0, 0, 0, chanserv_uptime, {"UPTIME", NULL, NULL, NULL, NULL}, NULL, "Shows the uptime statistics for the computer the bot is running on."},
//#endif
{INFO_COMMAND, 1, 0, 0, chanserv_user_list, {"USERLIST", "HLIST", "ACCESS", NULL, NULL}, NULL, "Show the bot's access list."},
{INFO_COMMAND, 0, 0, 0, chanserv_variables, {"VARIABLES", NULL, NULL, NULL, NULL}, NULL, "Displays variables you can use."},
#ifdef ENABLE_CTCP
{INFO_COMMAND, 0, 0, 0, chanserv_version, {"\1VERSION\1", NULL, NULL, NULL, NULL}, NULL, ""},
#endif
#ifdef ENABLE_CHANNEL
{NORMAL_COMMAND, 3, 1, 0, chanserv_voice, {"VOICE", "V", NULL, NULL, NULL}, "[#channel] <nicks>", "Add channel voice status to users."},
#endif
{SAFE_COMMAND, SLEEP_LEVEL, 0, 0, chanserv_wakeup, {"WAKEUP", NULL, NULL, NULL, NULL}, NULL, "Reactivates bot from sleep mode."},
#ifdef ENABLE_WEATHER
{NORMAL_COMMAND, 0, 1, 0, chanserv_weather, {"WEATHER", NULL, NULL, NULL, NULL}, "<city or code>", "Get decoded weather data."},
#endif
#ifdef ENABLE_WEBSEARCH
{NORMAL_COMMAND, 0, 1, 0, chanserv_websearch, {"WEBSEARCH", NULL, NULL, NULL, NULL}, "<text>", "Look up the text on the web using duckduckgo.com."},
#endif
{SAFE_COMMAND, 0, 2, 0, chanserv_where, {"WHAT", "WHO", "WHERE", NULL, NULL}, "<IS> [A|AN] <topic>", "Recall a topic."},
{SAFE_COMMAND, 0, 2, 0, chanserv_whisper, {"WHISPER", NULL, NULL, NULL, NULL}, "<nick> [ABOUT] <topic>", "Get bot to recall a topic to a user privately."},
{INFO_COMMAND, 4, 0, 0, NULL, {NULL, NULL, NULL, NULL, NULL}, NULL, NULL}
};
void chanserv(char *source, char *target, char *buf)
{
struct chanserv_output *result = NULL;
char *cmd = NULL, *userhost = NULL, oldbuf[BUFSIZ] = {"NULL"},
*ptr = NULL;
int i = 0, j = 0, found = -1, command = 0, wakeup = 0, exempt = 0,
more_needed = 0, too_many = 0, check_too_many = 0, arg_count = 0;
enum chanserv_invoke_type input_type = DIRECT_INVOKE;
enum chanserv_command_type command_type = NORMAL_COMMAND;
#ifdef ENABLE_RANDOM
if (strcasecmp (target, CHAN) == 0)
Rand_Idle = 0;
#endif
stripline (buf);
stripline (source);
if (buf == NULL || target == NULL || source == NULL)
return;
/* Make a copy of the original buffer in a safe location for
* later use. Strip the : if there is one.
*/
strncpy (oldbuf, buf, sizeof (oldbuf));
/* Pointer to oldbuf */
ptr = oldbuf;
if (*ptr == ':')
ptr++;
cmd = strtok (buf, " ");
if (!cmd)
return;
if (*cmd == ':')
cmd++;
if ((userhost = strchr (source, '!')) != NULL)
*userhost++ = '\0';
if (check_ignore_user_ram(source) > 0)
return;
if (*target != '#' && *target != '&' && *target != '+')
{
input_type = MSG_INVOKE;
}
else if (strcasecmp (cmd, NICK_COMMA) == 0 ||
strcasecmp (cmd, COLON_NICK) == 0 ||
strcasecmp (cmd, BCOLON_NICK) == 0 ||
strcasecmp (cmd, Mynick) == 0)
{
input_type = ADDRESS_INVOKE;
cmd = strtok (NULL, " ");
}
if (cmd)
{
if (*cmd == *CMDCHAR)
{
cmd++;
command = 1;
input_type = CHAR_INVOKE;
}
strupr (cmd);
for (i = 0; chanserv_commands[i].func != NULL; i++)
{
for (j = 0; chanserv_commands[i].command[j] != NULL; j++)
{
if (strcmp(cmd, chanserv_commands[i].command[j]) == 0)
{
found = i;
command_type = chanserv_commands[found].type;
check_too_many = chanserv_commands[found].too_many;
if (strcmp(cmd, "WAKEUP") == 0)
wakeup = 1;
break;
}
}
if (found != -1)
break;
}
}
if (input_type != MSG_INVOKE)
{
if (((Sleep_Toggle == 1) && (wakeup != 1)) || (cf(userhost, source, target)))
return;
add_user(target, source, userhost, 0); /* Unidle */
}
if (found != -1)
{
/*
* password related commands can ONLY be done privately.
* Every command can be done by /msg bot !command.
* Every command can be done by /query bot !command.
* Every command can be done by /msg bot !command.
* Every danger command can be done by bot: !command.
* Every danger command can be done by !command.
* Every normal command can be done by /query bot command.
* Every normal command can be done by /msg bot command.
* Every safe command can be done by bot: command.
* Every information command can be done by command.
*/
switch (command_type)
{
case INFO_COMMAND :
break;
case SAFE_COMMAND :
{
if (input_type == DIRECT_INVOKE)
return;
break;
}
case NORMAL_COMMAND :
{
if (input_type == DIRECT_INVOKE)
return;
break;
}
case DANGER_COMMAND :
{
if (command != 1)
return;
break;
}
case PASSWORD_COMMAND :
{
if (input_type != MSG_INVOKE)
return;
break;
}
}
if (check_access(userhost, (input_type == MSG_INVOKE) ? "#*" : target, 0, source) >= chanserv_commands[found].access)
{
char **args = NULL;
int k = 0;
/* Use the char count of spaces in our oldbuf ptr. Since
* it has the cmd tacked on the beginning, the number of
* spaces gives us an accurate early number of arguments
* supplied by the user, because the count of spaces will
* return one more than the actual number of args supplied.
* The first word is the cmd, so we don't want this counted.
* This is sort of a lazy way of counting arguments before
* they're actually read into a buffer and dealt with.
*
* This allows us to "break out" of the command routine if
* we've entered accidentally by user input. Such instances
* may be if the user says "info things stuff", the bot
* realizes this is not a command, but normal conversation,
* and will respond if the topic is in it's database. If it's
* not found, the bot either ignores it or responds with a
* whut reply if addressed directly. This code is only
* intended for commands which have no arguments.
*/
if (*ptr == '!')
ptr++;
/* Actual number of arguments supplied. */
k = count_char (ptr, ' ');
/* Number of arguments expected. */
arg_count = chanserv_commands[found].arg_count;
if (k > 0)
{
args = calloc(k + 1, sizeof(char *));
if (args)
{
for (i = 0; i < k; i++)
{
args[i] = strtok(NULL, " ");
}
args[i++] = NULL;
/* Check for more arguments needed, but don't
* bail out, we'll take care of it later. */
if (i < arg_count)
more_needed = 1;
}
else
return;
/* Check for too many args on special cases. */
if (check_too_many == 1)
{
if ((input_type == ADDRESS_INVOKE) && (k > (arg_count+1)))
too_many = 1;
if ((k > arg_count) && (input_type == DIRECT_INVOKE))
too_many = 1;
if ((k > arg_count) && (input_type == MSG_INVOKE))
too_many = 1;
if ((k > arg_count) && (input_type == CHAR_INVOKE))
return;
}
}
if (too_many == 1)
{
int i = 0;
char *ptr2 = NULL;
strlwr (ptr);
for (i = 0; i < strlen (ptr); i++)
{
if (ptr[i] == ' ')
ptr[i] = '+';
}
/* Strip the bot's nickname if ADDRESS_INVOKE */
if (input_type == ADDRESS_INVOKE)
{
ptr2 = strtok (ptr, "+");
ptr = strtok (NULL, "");
}
/* Output only if the topic exists. If the bot was
* addressed by nickname (ADDRESS_INVOKE), output
* anyway because show_url will supply a DUNNO
* response.
* If the input_type was MSG_INVOKE, we use the
* source as a target, because the target ends up
* being set to the bot's own nickname due to the
* parsing under certain conditions.
*/
if (check_existing_url(source, ptr, target) == 1)
// || (input_type == ADDRESS_INVOKE)
// || (input_type == MSG_INVOKE))
{
result = show_url(source, ptr,
((input_type == MSG_INVOKE)
? source : target), 1, 0, userhost, 0);
}
else
/* No matching database entry. */
return;
}
else if ((more_needed == 1) && chanserv_commands[found].syntax)
{
result = chanserv_show_help(cmd, check_access(userhost, (input_type == MSG_INVOKE) ? "#*" : target, 0, source));
}
else
{
/* We call this to give the command a chance to supply
* a custom error msg if there are not enough
* arguments. Because it fell through the loop
* this far, we assume it's a normal command with
* arguments to be parsed.
*/
result = chanserv_commands[found].func(source, target, cmd, args, input_type, userhost);
}
if (result)
{
i = 1;
show_output(source, target, result, input_type);
result = NULL;
}
free(args);
}
}
else if (input_type != CHAR_INVOKE)
{
if ((input_type == ADDRESS_INVOKE) && (cmd == NULL))
{
if (RANDOM_WHUT == true)
do_randomtopic(WHUTR, target, WHUT_FILE, source, cmd);
else
{
if (input_type == MSG_INVOKE)
S("NOTICE %s :%s\n", source, WHUT);
else
S("PRIVMSG %s :%s: %s\n", target, source, WHUT);
}
}
else if ((GENERAL_QUESTIONS) && (cmd))
{
result = show_url(source, get_multiword_topic(cmd),
(input_type == MSG_INVOKE) ? source : target,
(! (input_type == DIRECT_INVOKE)),
(input_type == DIRECT_INVOKE),
userhost, 0);
if (result)
{
show_output(source, (input_type == MSG_INVOKE) ? source : target, result, input_type);
result = NULL;
}
}
}
}
static void show_output(char *source, char *target, struct chanserv_output *result, enum chanserv_invoke_type input_type)
{
struct chanserv_output *output = result;
// TODO - This is not working for actions.
while (output)
{
char *s, *s2, c;
int length, len;
/* RFC2812 says max packet length is 512, including CR-LF at end.
* Also a colon and a space at the beginning.
*/
//#define MAX_IRC_LEN 507 // This doesn't work.
#define MAX_IRC_LEN 475 // This works.
s = output->output;
length = strlen(s);
if (input_type == MSG_INVOKE)
{
len = 12 + strlen(source);
while ((len + length) > MAX_IRC_LEN)
{
c = s[MAX_IRC_LEN - len];
s[MAX_IRC_LEN - len] = '\0';
s2 = strrchr(s, ' ');
*s2 = '\0';
S("NOTICE %s :%s\n", source, s);
db_sleep(2);
*s2 = ' ';
s[MAX_IRC_LEN - len] = c;
s = s2 + 1;
length = strlen(s);
}
S("NOTICE %s :%s\n", source, s);
}
else
{
len = 16 + strlen(target) + strlen(source);
while ((len + length) > MAX_IRC_LEN)
{
c = s[MAX_IRC_LEN - len];
s[MAX_IRC_LEN - len] = '\0';
s2 = strrchr(s, ' ');
*s2 = '\0';
S("PRIVMSG %s :%s: %s\n", target, source, s);
db_sleep(2);
*s2 = ' ';
s[MAX_IRC_LEN - len] = c;
s = s2 + 1;
length = strlen(s);
}
S("PRIVMSG %s :%s: %s\n", target, source, s);
}
output = output->next;
}
chanserv_output_free(result);
}
struct chanserv_output *chanserv_show_help(char *cmd, int user_level)
{
struct chanserv_output *result = NULL;
char temp[10 * 1024] = { 0 }, cmdchar[2] = "\0\0";
int i, j, found = -1;
if (*cmd == *CMDCHAR)
cmd++;
strupr(cmd);
for (i = 0; chanserv_commands[i].func != NULL; i++)
{
for (j = 0; chanserv_commands[i].command[j] != NULL; j++)
{
if (strcmp(cmd, chanserv_commands[i].command[j]) == 0)
{
found = i;
break;
}
}
if (found != -1)
break;
}
if (found != -1)
{
if (chanserv_commands[found].type == DANGER_COMMAND)
cmdchar[0] = *CMDCHAR;
else
cmdchar[0] = '\0';
for (j = 0; chanserv_commands[found].command[j] != NULL; j++)
{
if (j)
strcat(temp, " | ");
if (chanserv_commands[i].type == DANGER_COMMAND)
strcat(temp, cmdchar);
strcat(temp, chanserv_commands[found].command[j]);
}
result = chanserv_asprintf(result, "%s [level %d] - %s SYNTAX - %s%s %s", temp, chanserv_commands[found].access, chanserv_commands[found].summary, cmdchar, cmd,
(chanserv_commands[found].syntax != NULL) ? chanserv_commands[found].syntax : "");
}
else if (strcmp(cmd, "COMMANDS") == 0)
{
cmdchar[0] = *CMDCHAR;
for (i = 0; chanserv_commands[i].func != NULL; i++)
{
if (chanserv_commands[i].access <= user_level)
{
if (chanserv_commands[i].command[0][0] > 10)
{
if (i)
strcat(temp, " ");
if (chanserv_commands[i].type == DANGER_COMMAND)
strcat(temp, cmdchar);
strcat(temp, chanserv_commands[i].command[0]);
}
}
}
result = chanserv_asprintf(result, "%s", temp);
}
else if (strcmp(cmd, "PARAMETERS") == 0)
{
for (i = 0; parameters[i].parameter[0] != NULL; i++)
{
if (parameters[i].access <= user_level)
{
if (i)
strcat(temp, " ");
strcat(temp, parameters[i].parameter[0]);
}
}
result = chanserv_asprintf(result, "%s", temp);
}
else
{
for (i = 0; parameters[i].parameter[0] != NULL; i++)
{
for (j = 0; parameters[i].parameter[j] != NULL; j++)
{
if (strcmp(cmd, parameters[i].parameter[j]) == 0)
{
found = i;
break;
}
}
if (found != -1)
break;
}
if (found != -1)
{
for (j = 0; parameters[found].parameter[j] != NULL; j++)
{
if (j)
strcat(temp, " | ");
strcat(temp, parameters[found].parameter[j]);
}
switch (parameters[found].type)
{
case ST_BOOLEAN :
{
bool *variable = parameters[found].value;
result = chanserv_asprintf(result, "%s [level %d] - %s VALUE - %s = %s", temp, parameters[found].access, parameters[found].summary, cmd, (*variable) ? "true" : "false");
break;
}
case ST_INTEGER :
{
long *variable = parameters[found].value;
result = chanserv_asprintf(result, "%s [level %d] - %s VALUE - %s = %ld", temp, parameters[found].access, parameters[found].summary, cmd, *variable);
break;
}
case ST_STRING :
{
char *variable = parameters[found].value;
result = chanserv_asprintf(result, "%s [level %d] - %s VALUE - %s = %s", temp, parameters[found].access, parameters[found].summary, cmd, variable);
break;
}
}
}
}
return result;
}
int check_exempt (char *cmd)
{
int i = 0;
int j = 0;
int k = 0;
char *exempt_items[] = {
"CYCLE",
"HELP",
#ifdef ENABLE_STATS
"STATS",
#endif
NULL
};
strupr(cmd);
for (i = 0; chanserv_commands[i].func != NULL; i++)
{
for (j = 0; chanserv_commands[i].command[j] != NULL; j++)
{
if (strcmp (cmd, chanserv_commands[i].command[j]) == 0)
{
for (k = 0; exempt_items[k] != NULL; k++)
{
if (strcmp (chanserv_commands[i].command[j], exempt_items[k]) == 0)
{
strlwr(cmd);
return 1;
}
}
}
}
}
strlwr(cmd);
return 0;
}
diff --git a/source/defines.h b/source/defines.h
index 7f8a607..5e61802 100644
--- a/source/defines.h
+++ b/source/defines.h
@@ -1,344 +1,344 @@
/* @configure_input@ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* defines.h
*** Darkbot (c) 2002
* The Internet Relay Chat Talking Robot
*
- *** Darkbot Creator - Jason Hamilton (play) Jason@superlink.net
- * Project Administrator - LuizCB (Pincel) LuizCB@darkbot.info
- * Recent Code Modifications - Ron (`ron) ron@freezedown.org
+ *** Darkbot Creator : Jason Hamilton (play) Jason@superlink.net
+ * Project Administrator : LuizCB (lcb) LuizCB@dusers.sourceforge.net
+ * Lead Developer : David Seikel (onefang) onefang@users.sourceforge.net
*
- * Official Sites: http://www.freezedown.org
+ * Official Site: http://darkbot.sourceforge.net
* http://darkbot.sourceforge.net
*
*** For any questions, suggestions, malfunctions, etc
- * Use our support forum at http://forum.freezedown.org
+ * Use our support area at http://darkbot.sourceforge.net
*
* *******************************---******************************* */
/*
*** NOTES - READ before you start:
*** Lines beginning by # (hash) are peprocessor directives, they are not
* comments. You should NOT remove them.
*** #defines should only be changed to ON, OFF, #define, #undef
* or it's value defined on the very right end.
*** Areas between " " are messages Darkbot will send. Do not remove " ".
*** Double slash characters on de beginning of a line or slaches followed
* or preceded by * on the beginning and end of lines envolving some
* portion of text are comment characters combinations with help
* information for the delelopers or users. They do not have any effect
* in the behavior of the program.
*
,-----------------------------------------------------------------,
| Note that the defines bellow are the RECOMMENDED settings! |
| Modify it by changing it's values of the data. This file will |
| instruct the compiler to build the executable file. If you're |
| not sure of what to do, leave the default settings alone :) |
`-----------------------------------------------------------------' */
#define ON 1
#define OFF 0
/* ================ SYSTEM REQUIREMENTS ================ */
/*
* Change the Ansi C signal handling below if it's not in the standard place,
* usually on include/. Leave it as is if you don't know what that is. Type
* 'man signal' on your unix box for more info.
* (default = <signal.h>)
*/
//#include <signal.h>
/*
* Most BSD systems will not need this. If your bot will
* connect but don't react at all try turning this ON.
* (default = OFF)
*/
//#define NEED_LIBC5 OFF
/*
* SGI boxes (ie; IRIX system) need this
* define to run. (default = OFF)
*/
//#define SGI OFF
/*
* If you change anything on the next 5 directives be careful not to
* remove or change the position of '%s' nor anything outside quotes.
*/
#define L100(s,a,b,c,d,e,f) S("NOTICE %s :I can be triggered by various \
forms of speech, all which must be addressed to me, in one of the \
following formats: %s %s %s or even %s .... In my database, you can \
find a topic by saying my nick, <topic> . eg; \37%s nuke\37 ..... \
to do a search on a word, or partial text, just type: <mynick>, search \
<text> ... eg; \37%s search nuke\37\n",s,a,b,c,d,e,f)
#define L101(a,b,c,d) S("NOTICE %s :I can also be triggered with even more \
human formats: \37%s who is bill gates?\37 .. You can also phrase it \
in a question: \37%s where is msie?\37 ...For more info \
-about me, visit http://www.freezedown.org\n",a,b,c,d)
+about me, visit http://darkbot.sourceforge.net\n",a,b,c,d)
#define L102(a,b,c,d) S("NOTICE %s :Welcome to %s, %s. Before \
asking your question, type %cHELP for a list of help topics.\n", a,b,c,d)
/* *******************************---******************************* */
/* --------------- Don't change anything else below! --------------- */
/* ***************************************************************** */
//#include <sys/cdefs.h>
//#include <sys/param.h>
//#include <pwd.h>
/* Here we sort out what to do based on some autoconf detected things. */
#if defined _WIN32 || defined __CYGWIN__ || defined __CYGWIN32__ || defined __MINGW32__
# ifndef WIN32
# define WIN32
# endif
#endif
#define _GNU_SOURCE 1
#if HAVE_ANSIDECL_H
#include <ansidecl.h>
#endif
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
#if HAVE_ERRNO_H
# include <errno.h>
#endif
#ifndef errno
extern int errno;
#endif
#if HAVE_NETDB_H
# include <netdb.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#if HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#include <assert.h>
#if HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef WIN32
# include <windows.h>
#endif
#include <signal.h>
#include <sys/stat.h>
#include <stdio.h> /* The only one we can guarantee. */
#if HAVE_STDBOOL_H
# include <stdbool.h>
#else
# if ! HAVE__BOOL
# ifdef __cplusplus
typedef bool _Bool;
# else
typedef unsigned char _Bool;
# endif
# endif
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
#endif
#if STDC_HEADERS
# include <string.h>
# include <stdarg.h>
# include <stdlib.h>
#else
# if !HAVE_STRCHR
# define strchr index
# define strrchr rindex
# endif
char *strchr (), *strrchr ();
# if !HAVE_MEMMOVE
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#if HAVE_UNISTD_H
#include <sys/types.h>
#include <unistd.h>
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
/* MacOS X is happier with this one AFTER timeval is declared. */
#include <sys/resource.h>
#include "stat-macros.h"
#include "minmax.h"
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# define EXIT_FAILURE 1
#endif
#if !LSTAT_FOLLOWS_SLASHED_SYMLINK
extern int rpl_lstat (const char *name, struct stat *buf);
# undef lstat
# define lstat rpl_lstat
#endif
#if !HAVE_MEMSET
# define memset rpl_memset
#endif
#if !HAVE_NANOSLEEP
# define nanosleep rpl_nanosleep
#endif
#if !HAVE_SNPRINTF
# define snprintf rpl_snprintf
#endif
#if !HAVE_STRCASECMP
# define strcasecmp rpl_strcasecmp
#endif
#if !HAVE_STRCASESTR
# define strcasestr rpl_strcasestr
#endif
#if !HAVE_STRNDUP
extern char *rpl_strndup (const char *dupMe, size_t maxBytes);
# undef strndup
# define strndup rpl_strndup
#endif
#if !HAVE_STRSPN
# define strspn rpl_strspn
#endif
#if !HAVE_STRSTR
# define strstr rpl_strstr
#endif
#if !HAVE_VPRINTF
# define vsprintf rpl_vsprintf
# define vfprintf rpl_vfprintf
#endif
#if !HAVE_LIBCRYPT
# if !HAVE_CRYPT
# define crypt rpl_crypt
# endif
#endif
/* -------------------------------------------------- */
#define FR 3 /* these two are the # of lines per secs */
#define FT 3
#define AIL 1
#define WSEC 10
#define USEC 0
#define RECHECK 45
#define DEFAULT_DBTIMERS_PATH "timers"
#define DEFAULT_LOG_DIR "logs/"
#define DEFAULT_RDB_DIR "rdb"
#ifdef ENABLE_STATS
#define DEFAULT_STATS_FILE "stats.db"
#endif
#define DEFAULT_SEEN_FILE "seen.db"
#define DEFAULT_URL2 "info2.db"
#define DUNNO_FILE "dunno"
#define WHUT_FILE "whut"
#define DEFAULT_BACKUP_DUP "backup_dups.db"
#define DEFAULT_ADD_DELETES "logs/add_delete.log"
#define TMP_URL ".info.tmp"
#define TMP_FILE ".file.tmp"
#define DEFAULT_AUTOTOPIC_F "autotopic.ini"
#define DEFAULT_HELPER_LIST "userlist.db"
#define DEFAULT_QUIZ_FILE "quiz.db"
#define DEFAULT_PERFORM "perform.ini"
#define DEFAULT_DEOP "deop.ini"
#define DEFAULT_RAND_SAY "random.ini"
#define DEFAULT_RAND_FILE "randomstuff.ini"
#define DEFAULT_RANDQ_TEMPFILE "randq.tmp"
#define DEFAULT_RAND_BACKUP_FILE "randomstuff.bak"
#define DEFAULT_SERVERS "servers.ini"
#define DEFAULT_PERMBAN "permbans.db"
#define DEFAULT_SETUP "setup.ini"
#define MAX_SEARCH_LENGTH 350
#define ERR_SOCK_OPT -1
#define ERR_TIMED_OUT -1
#define ERR_CANT_MALLOC -1
#define ERR_OPEN_SOCKET -2
#define ERR_CONN_REFUSED -2
#define ERR_NOT_ADDR -3
#define ERR_WRITE_SOCKET -3
#define ERR_NO_REACH -4
#define ERR_CANT_CONNECT -5
#define ERR_READ_SOCKET -5
#define ERR_SERVER_BUSY -6
#define ERR_NO_DOCUMENTS -6
#define ERR_NO_DATA -7
#define SUCCESS 0
#define LEGAL_TEXT "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"
#define SAFE_LIST "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
#define LEGAL_NICK_TEXT "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-\\|[]{}`"
#define NUMBER_LIST "1234567890"
#define MAX_NICK_LENGTH 35
#ifndef LANG /* If not defined, default to english */
#define LANG 1
#endif
#define NORMALR 0
#define WHUTR 1
#define DUNNOR 2
#define RAND_NORMAL 0
#define RAND_ACTION 1
#define RAND_RAW 2
#define RANDQ_NORMAL 0
#define RANDQ_CASE 1
#define RANDQ_RAND 2
#define RDB_NORMAL 0
#define RDB_ACTION 1
#define RDB_RAW 2
/* ////////////////////////////////////////////////////////////////////// */
#define RESERVED1 "EXPLAIN"
#define RESERVED2 "DECLARE"
#include "langs/lang.h"
diff --git a/source/langs/arabic.h b/source/langs/arabic.h
index 804bc25..60a1e4c 100644
--- a/source/langs/arabic.h
+++ b/source/langs/arabic.h
@@ -1,101 +1,101 @@
#define I_SPEAK "I speak Arabic."
#define L001(a,b) S("PRIVMSG %s :Lam tada3 kalimate Morour, Li wad3i Kalimate Morour: \2/msg %s PASS <kalimate Morour 9adima> <kalimate Morour Jadida>\2 (Bima Anaha hya Al Marra Oula Allati takhtaro fiha kalimate Morour , Ista3mile '0' Sifr Ka kalimate Morour 9adima)\n",a,b)
#define L002(a,b,c) S("NOTICE %s :7odifa Ban Da4im #%d, %s.\n",a,b,c)
#define L003(a,b) S("NOTICE %s :Ghayr 9adir 3ala fat7 %s :(\n",a,b)
#define L004(a,b,c) S("PRIVMSG %s :%s, honaka %d SEEN's fi 9a3idat bayanati.\n",a,b,c)
#define L005(a,b) S("PRIVMSG %s :3alayka an ta3rifa akthar mini 7awla hada al mawdou3, %s.\n",a,b)
#define L006(a,b,c,d) S("PRIVMSG %s :%s, Lam ara %s %s\n",a,b,c,d)
#define L007(a,b) S("NOTICE %s :Autotopic 3ala %s hia OFF\n",a,b)
#define L008(a,b) S("NOTICE %s :Autotopic on %s hya l4an OFF\n",a,b);
#define L009(a,b,c) S("NOTICE %s :AUTOTOPIC @ %s ON: %s\n",a,b,c)
#define L010(a,b,c) S("NOTICE %s :AUTOTOPIC @ %s 7odetha: %s\n",a,b,c)
#define L011(a,b,c) S("PRIVMSG %s :%s, Anhayte. Honaka l2ana %d min al achya2 al 3achwa2iya.\n",a,b,c)
#define L012(a,b) S("NOTICE %s :kalimte Morour li %s 9ad Jodithate.\n",a,b)
#define L013(a) S("NOTICE %s :kalimate Morour khat2a!\n",a)
#define L014(a) S("NOTICE %s :ghayr mawjood!\n",a)
#define L015(a,b,c,d) S("NOTICE %s :7odifa al Mostakhdim: %s [%d:%d]\n",a,b,c,d)
#define L016(a,b) S("PRIVMSG %s :%s: ta9ssim bi Sifr khata2!\n",a,b)
#define L017(a,b) S("PRIVMSG %s :%s: 3amalia ghayr 9anounia!\n",a,b)
#define L018(a,b,c,d,e) S("KICK %s %s :%s (idafatoka il tajahol #%d: %s)\n",a,b,c,d,e)
#define L019(a,b,c) S("PRIVMSG %s :idafatoka ila tajahol #%d: %s!\n",a,b,c);
#define L020(a,b,c,d) S("NOTICE %s :7oditha #%d: \37[\37%s\37]\37 Ma3loumate\2:\2 %s\n",a,b,c,d)
#define L021(a,b,c,d) S("PRIVMSG %s :%s \37%s\37.. %d Madda bo7itate.\n",a,b,c,d)
#define L022(a,b,c) S("PRIVMSG %s :Wajadto akthar min \37%d\37 min fadlek ij3al ba7thaka akthar di9a\2:\2 \%s\n",a,b,c);
#define L023(a,b,c) S("PRIVMSG %s :wajadto \37Motatabi9\37 Wa7eda, %s\2:\2 %s\n",a,b,c)
#define L024(a,b,c,d) S("PRIVMSG %s :wajadto \37%d\37 Motatabi9, %s\2:\2 %s\n",a,b,c,d)
#define L025(a,b) S("PRIVMSG %s :wajadto %ld madkhal motachabih. 9ad 7odifou.\n",a,b)
#define L026(a,b,c,d,e,f,g,h,i,j,k,l) S("PRIVMSG %s :Astakhdimo %s. Ladaya %ld mawadee3 fi 9a3idate bayanaty, moshaghal limodaate: %d yawm%, %02d:%02d, honaka %ld as2ila tori7at, %ld mawdoo3 odifa, and %ld mawdoo3 7odifa, Mondo an Wasalte. Wa9te Al 3amalia: %1.4lf sec%s\n",a,b,c,d,e,f,g,h,i,j,k,l)
#define L027(a,b,c,d,e,f,g,h,i,j,k,l) S("PRIVMSG %s :Astakhdimo %s. ladaya %ld mawadee3 fi 9a3idate bayanaty, moshaghal limodaate: %d sa3at%s, %d da9i9a%s, honaka %ld as2ila tori7at, %ld mawdoo3 odifa, and %ld mawdoo3 7odifa, Mondo an Wasalte. wa9t al 3amalia: %1.4lf sec%s\n",a,b,c,d,e,f,g,h,i,j,k,l)
#define L028(a,b,c,d,e,f,g,h,i,j,k,l) S("PRIVMSG %s :Astakhdimo %s. Ladaya %ld mawadee3 fi 9a3idate bayanaty, moshaghal limodaate: %d min%s, %d sec%s, honaka %ld as2ila tori7at, %ld mawdoo3 odifa, and %ld mawdoo3 7odifa, Mondo an Wasalte. wa9t al 3amalia: %1.4lf sec%s\n",a,b,c,d,e,f,g,h,i,j,k,l)
#define L029(a,b,c,d) S("PRIVMSG %s :%s: La9ad 7adaftou al mawdou3 #%ld, \2%s\2.\n",a,b,c,d)
#define L029n(a,b,c,d) S("NOTICE %s :%s: La9ad 7adaftou al mawdou3 #%ld, \2%s\2.\n",a,b,c,d)
#define L030(a,b,c) S("PRIVMSG %s :%s\2:\2 lam yakoun fii stita3aty woujouda al mawdou3 %s. 3amaliyat al 7adf fashilate.\n",a,b,c)
#define L030n(a,b,c) S("NOTICE %s :%s\2:\2 lam yakoun fii stita3aty woujouda al mawdou3 %s. 3amaliyat al 7adf fashilate.\n",a,b,c)
#define L031(a,b) S("NOTICE %s :A Tari9a: \2/msg %s PASS <kalimate Morour 9adima> <kalimate Morour Jadida>\2\n",a,b)
#define L032(a) Snow("QUIT :K\2\2illed (%s (li anani 9olto kadalik!))\n",a)
#define L033(a) S("NOTICE %s :A Tari9a: UP <#chan> <kalimate Morour>\n",a)
#define L034(a) S("NOTICE %s :A Tari9a: OP <#chan> [la9ab] <kalimate Morour>\n",a)
#define L035(a) S("NOTICE %s :A Tari9a: DEOP <#chan> [la9ab] <kalimate Morour>\n",a)
#define L036(a) S("NOTICE %s :7adid la9ab!\n",a)
#define L037(a,b) S("NOTICE %s :Asta3id li /nick %s\n",a,b)
#define L038(a,b) S("NOTICE %s :O7awil /nick %s-dork.\n",a,b)
#define L039(a,b) S("PRIVMSG %s :Moghadir %s\n",a,b)
#define L040(a,b) S("PRIVMSG %s :Dokhoul %s\n",a,b)
#define L041(a) S("PRIVMSG %s :7adid la9ab/9anate!\n",a)
#define L042(a) S("NOTICE %s :Adkhil user@host Li takhaloss minh!\n",a)
#define L043(a) S("NOTICE %s :La youjad ayo ban.\n",a)
#define L044(a) S("NOTICE %s :Adkhil user@host Lil 7adf!\n",a)
#define L045(a) S("NOTICE %s :wa ida lam af3al kadalik??\n",a)
#define L046(a) S("PRIVMSG %s :9a3idate al bayanate 9ad do3imate.\n",a)
#define L047(a,b) S("NOTICE %s :A Tari9a: %cAUTOTOPIC <Mawdou3> (Da3 \"0\" Lil 2itfa2)\n",a,b)
#define L048(a) S("NOTICE %s :A Tari9a: SETCHAN <9anate jadida>\n",a)
#define L049(a,b) S("NOTICE %s :9anat Ra2issiya: %s\n",a,b)
#define L050(a) S("NOTICE %s :A Tari9a: SETCHAR <ARRamz al jadid>\n",a)
#define L051(a,b) S("NOTICE %s :Ramz al 9iyada al aana: %c\n",a,b)
#define L052(a) S("NOTICE %s :A Tari9a: SETUSER <howia jadida> (Yatattalab I3adat Atachghil)\n",a)
#define L053(a,b) S("NOTICE %s :al hawia al asslia l'aan: %s\n",a,b)
#define L054(a) S("NOTICE %s :A Tari9a: SETNICK <La9ab Jadid>\n",a)
-#define L055(a) S("NOTICE %s :A Tari9a: ADDUSER <#9anate> <*user@*.host> <Daraja> <Kalimate Morour>. ie; ADDUSER #darkbot *bot@*.darkbot.info 3 kalimate Morourih... Ista3mil #* Ida Aradta i3ta2aho Madkhal Fi Jamee3 al 9anawate.\n",a)
+#define L055(a) S("NOTICE %s :A Tari9a: ADDUSER <#9anate> <*user@*.host> <Daraja> <Kalimate Morour>. ie; ADDUSER #darkbot *bot@*.UPDATE.THIS.PLEASE 3 kalimate Morourih... Ista3mil #* Ida Aradta i3ta2aho Madkhal Fi Jamee3 al 9anawate.\n",a)
#define L056(a) sprintf(temp, "Lam astakhdim \2%cSETINFO\2 Ba3d!",a)
#define L057(a,b,c) S("NOTICE %s :Odifa Al Mostakhdem: %s - level %d\n",a,b,c)
#define L058(a,b,c) S("NOTICE %s :A Tari9a: %c%s <user@host> [Sabab]\n",a,b,c)
#define L059(a,b,c,d) S("NOTICE %s :Odifa fi al ban Da2im #%d, %s; Sabab: %s\n",a,b,c,d)
#define L060(a) S("NOTICE %s :A Tari9a: I3adat <Kam min Marra> <Modda> <bayanate-raw>\n",a)
#define L061(a) S("NOTICE %s :Otmima.\n",a)
#define L062(a) S("QUIT :I3ada Tachghil %s ...\n",a);
#define L064(a,b) S("PRIVMSG %s :%s, Mada Torido An Todife?\n",a,b)
#define L064n(a,b) S("NOTICE %s :%s, Mada Torido An Todife?\n",a,b)
#define L065(a,b) S("PRIVMSG %s :Idafate Mada, %s?\n",a,b);
#define L066(a,b,c) S("PRIVMSG %s :%s: Ayate ma3loumate yajibe an todafa %s?\n",a,b,c)
#define L067(a,b) S("PRIVMSG %s :7assanan, %s :)\n",a,b)
#define Lbadtopic(a,b) S("PRIVMSG %s :Assif %s, Lakena Daa3ma Li dalika al Mawdou3 9ad Ozile.\n",a,b);
#define Lbadtopic2(a,b) S("NOTICE %s :Assif %s, Lakena Daa3ma Li dalika al Mawdou3 9ad Ozile.\n",a,b);
#define L065n(a,b) S("NOTICE %s :Idafate Mada, %s?\n",a,b);
#define L066n(a,b,c) S("NOTICE %s :%s: Ayate ma3loumate yajibe an todafa %s?\n",a,b,c)
#define L067n(a,b) S("NOTICE %s :7assanan, %s :)\n",a,b)
#define L068(a,b) S("PRIVMSG %s :Astabdile Mada, %s?\n",a,b)
#define L069(a,b,c) S("PRIVMSG %s :%s: Ayate ma3loumate yajibe an astabdile %s?\n",a,b,c)
#define L070(a,b,c) S("PRIVMSG %s :%s, %s 9ad Joddida.\n",a,b,c)
#define L071(a,b,c,d) S("PRIVMSG %s :Honaka %d ban Da2im%s fi Dakira.\n",a,b,c,d)
#define L073(a,b,c) S("PRIVMSG %s :%s, %d tania marrate 9able al achya2 al 3achwa2iya\n",a,b,c)
#define L074(a,b,c) S("PRIVMSG %s :%s: Fiha %d Ramz.\n",a,b,c)
#define L075(a,b,c,d) S("PRIVMSG %s :%s, Honaka 7aalian %d mawdou3%s fi 7alate intidar.\n",a,b,c,d)
#define L076(a,b) S("PRIVMSG %s :Ra2ayto %d yandam 7ata al ana.\n",a,b)
#define L077(a,b,c,d,e) S("PRIVMSG %s :Honaka %s %d khadim%s Fi 9a2imate khoddami. Ana 7alian Fi Al khadim #%d.\n",a,b,c,d,e)
#define L078(a,b,c) S("PRIVMSG %s :%s, Ramz 9iyadaty howa: %c\n",a,b,c)
#define L079(a,b,c) S("PRIVMSG %s :Mada yajib An %O7arrire li, %s?\n",a,b,c)
#define L080(a,b) S("PRIVMSG %s :%s, Ta7taj lita7did 3onwane!\n",a,b)
#define L081(a,b) S("PRIVMSG %s :Ghayre 9adir 3ala Nadar a3la %s.\n",a,b)
#define L083(a,b,c) S("PRIVMSG %s :%s: Mada torido an Okhbir %s?\n",a,b,c)
#define L083n(a,b,c) S("NOTICE %s :%s: Mada torido an Okhbir %s?\n",a,b,c)
#define L084(a,b,c) S("PRIVMSG %s :%s, Okhbir %s 7awla Mada?\n",a,b,c)
#define L084n(a,b,c) S("NOTICE %s :%s, Okhbir %s 7awla Mada?\n",a,b,c)
#define L085(a,b) S("PRIVMSG %s :Okhbir Man, %s?\n",a,b)
#define L085n(a,b) S("NOTICE %s :Okhbir Man, %s?\n",a,b)
#define L086(a,b) S("PRIVMSG %s :%s\2:\2 A tas2ale?\n",a,b)
#define L086n(a,b) S("NOTICE %s :%s\2:\2 A tas2ale?\n",a,b)
#define L087(a,b,c,d,e) S("PRIVMSG %s :%s %s %s? A3id siyaghate dalika? (A tari9a %cHELP Lilmossa3ada 7awla Na7we)\n",a,b,c,d,e)
#define L087n(a,b,c,d,e) S("NOTICE %s :%s %s %s? A3id siyaghate dalika? (A tari9a %cHELP Lilmossa3ada 7awla Na7we)\n",a,b,c,d,e)
#define L088(a) S("QUIT :%s Mo7ashashe!\n",a)
#define L089(a) S("PRIVMSG %s :\1ACTION Yastay9id...\1\n",a)
#define L090(a,b) S("PRIVMSG %s :Ata3arad lil'flood. Irssal 9a2imate al intidar (al ma3loumate fi intidar al irssal). %d Band 7odifa.\n",a,b)
diff --git a/source/main.c b/source/main.c
index 58187ac..58d730a 100644
--- a/source/main.c
+++ b/source/main.c
@@ -1,215 +1,214 @@
#include "defines.h"
#include "vars.h"
#include "prototypes.h"
/**
* 6/23/00 Dan:
* - Moved declaration of newact into #ifdef
*/
int
main (int argc, char **argv)
{
char temp[STRING_SHORT] = { 0 };
char exe[STRING_SHORT] = { 0 };
struct timeval timeout;
int ret, i = 0;
fd_set fdvar;
struct stat st;
#ifdef SA_NOCLDSTOP
struct sigaction newact;
#endif
#ifdef DEBUG
DebuG = 1;
#endif
get_s ();
srand (time (0));
uptime = time (NULL);
strncpy (DARKBOT_BIN, argv[0], sizeof (DARKBOT_BIN));
strncpy (exe, argv[0], sizeof (exe)); /* Coz basename() may modify it's argument. */
#ifdef DATABASEDIR
strncpy (DAT_DIR, DATABASEDIR, sizeof (DAT_DIR));
#else
strncpy (DAT_DIR, "dat", sizeof (DAT_DIR));
#endif
#ifdef SOURCEDIR
/* Check if this is being run from the build directory before being installed. */
snprintf(temp, sizeof(temp), "%s/dat/setup.ini", SOURCEDIR);
if (stat(temp, &st) >= 0)
{
snprintf(temp, sizeof(temp), "%s/dat", SOURCEDIR);
strncpy(DAT_DIR, temp, sizeof (DAT_DIR));
}
#endif
/* Parse the command line arguements, if there are any. */
if (argv[1] != NULL)
{
for (i = 1; i < argc; i++)
{
if (argv[i][0] == '-')
{
if (argv[i][1] == 'S')
{
SeeN = true;
}
else if (argv[i][1] == 'D')
{
DebuG = 1;
}
else if (argv[i][1] == 'I')
{
strcpy (DAT_DIR, argv[++i]);
printf ("DAT_DIR: Using %s.\n", DAT_DIR);
}
else
{
printf ("\n\n%s HELP:\n\n", dbVersion);
printf ("%s (Launches Darkbot to IRC)\n", argv[0]);
printf ("%s -SEEN (Enables SEEN [Even if SEEN is undefined])\n", argv[0]);
printf ("%s -DEBUG (Launch in debug mode)\n", argv[0]);
exit (0);
}
}
}
}
if (SeeN)
{
printf ("\nSEEN ENABLED.\n");
}
if (DebuG == 1)
{
printf ("\nDEBUG ENABLED.\n");
}
set_paths ();
/* This is the best way to deternmine if sigaction() can be used.
* sigaction() is more portable than signal(), so use it if we can. */
#ifdef SA_NOCLDSTOP
newact.sa_handler = sig_alrm;
sigemptyset (&newact.sa_mask);
newact.sa_flags = 0;
sigaction (SIGALRM, &newact, NULL);
newact.sa_handler = sig_segv;
sigemptyset (&newact.sa_mask);
newact.sa_flags = 0;
sigaction (SIGSEGV, &newact, NULL);
newact.sa_handler = sig_hup;
sigemptyset (&newact.sa_mask);
newact.sa_flags = 0;
sigaction (SIGHUP, &newact, NULL);
#else
signal (SIGALRM, sig_alrm);
signal (SIGSEGV, sig_segv);
signal (SIGHUP, sig_hup);
#endif
#ifdef ENABLE_RANDOM
get_rand_stuff_time ();
#endif
printf ("\n\n\n");
printf (" * * * * * * * * Darkbot (c) 1996 v8 Release Candidate 4 * * * * * * * * * \n");
- printf (" * The IRC Talking Robot * \n");
+ printf (" * The IRC Talking Robot * \n");
printf (" * * \n");
- printf (" * Creator/Author: Jason <jason@superlink.net> * \n");
- printf (" * Project Administrator: juice <juice@freezedown.org> * \n");
- printf (" * Last major code changes: ron <ron@freezedown.org> * \n");
- printf (" * Last major code changes: onefang <onefang@gmail.com> * \n");
+ printf (" * Creator/Author : Jason <jason@superlink.net> * \n");
+ printf (" * Project Administrator: LuizCB <LuizCB@users.sourceforge.net> * \n");
+ printf (" * Lead Devekloper : onefang <onefang@users.sourceforge.net> * \n");
printf (" * Please check docs/contributors for a list of collaborators * \n");
printf (" * * \n");
- printf (" * Eventual malfunction, suggestions or patches use only * \n");
- printf (" * Support Forum @ http://forum.freezedown.org * \n");
+ printf (" * Eventual malfunction, suggestions or patches use only * \n");
+ printf (" * Darkbot official site @ http:/darkbot.sourceforge.net * \n");
printf (" * * \n");
printf (" * By running this installation you agree that this program is provided * \n");
printf (" * free for non-commercial use only; - Distribution of modified source * \n");
printf (" * code or binaries compiled from modified source code for any platform * \n");
printf (" * or OS is expressly forbidden. - This program is only available at * \n");
- printf (" * http://www.freezedown.org * \n");
+ printf (" * http://darkbot.sourceforge.net * \n");
printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n");
#ifndef WIN32
# ifdef ENABLE_VERSION_CHECK
- snprintf (temp, sizeof (temp), "lynx -source http://www.freezedown.org/cgi/laun.cgi?%s &", dbVersion);
+ snprintf (temp, sizeof (temp), "lynx -source http://darkbot.sourceforge.net/cgi/laun.cgi?%s &", dbVersion);
ret = system (temp);
# endif
db_sleep (2);
if (SORT)
{
printf ("Sorting database...\n");
snprintf (temp, sizeof (temp), "sort %s -o %s\n", URL2, URL2);
ret = system (temp);
}
#endif
load_helpers ();
#ifdef ENABLE_STATS
load_stats ();
#endif
check_files ();
raw_now ("SERVERS");
raw_now ("SETUP");
raw_now ("PERMBAN");
alarm (AIL);
prepare_bot ();
register_bot ();
while (1)
{
timeout.tv_sec = WSEC;
timeout.tv_usec = USEC;
FD_ZERO (&fdvar);
FD_SET (socketfd, &fdvar);
switch (select (NFDBITS, &fdvar, (fd_set *) NULL, (fd_set *) NULL, &timeout))
{
case 0:
break;
case -1:
if (!alarmed)
{
db_sleep (RECHECK);
}
else
alarmed = 0;
break;
default:
parse_server_msg (&fdvar);
break;
}
}
}
void set_paths (void)
{
int ret;
snprintf (DBTIMERS_PATH, sizeof (DBTIMERS_PATH), "%s/%s", DAT_DIR, DEFAULT_DBTIMERS_PATH);
ret = mkdir(DBTIMERS_PATH, S_IRWXU);
snprintf (LOG_DIR, sizeof (LOG_DIR), "%s/%s", DAT_DIR, DEFAULT_LOG_DIR);
ret = mkdir(LOG_DIR, S_IRWXU);
snprintf (RDB_DIR, sizeof (RDB_DIR), "%s/%s", DAT_DIR, DEFAULT_RDB_DIR);
ret = mkdir(RDB_DIR, S_IRWXU);
#ifdef ENABLE_STATS
snprintf (STATS_FILE, sizeof (STATS_FILE), "%s/%s", DAT_DIR, DEFAULT_STATS_FILE);
#endif
snprintf (SEEN_FILE, sizeof (SEEN_FILE), "%s/%s", DAT_DIR, DEFAULT_SEEN_FILE);
snprintf (URL2, sizeof (URL2), "%s/%s", DAT_DIR, DEFAULT_URL2);
snprintf (BACKUP_DUP, sizeof (BACKUP_DUP), "%s/%s", DAT_DIR, DEFAULT_BACKUP_DUP);
snprintf (AUTOTOPIC_F, sizeof (AUTOTOPIC_F), "%s/%s", DAT_DIR, DEFAULT_AUTOTOPIC_F);
snprintf (HELPER_LIST, sizeof (HELPER_LIST), "%s/%s", DAT_DIR, DEFAULT_HELPER_LIST);
snprintf (QUIZ_FILE, sizeof (QUIZ_FILE), "%s/%s", DAT_DIR, DEFAULT_QUIZ_FILE);
snprintf (PERFORM, sizeof (PERFORM), "%s/%s", DAT_DIR, DEFAULT_PERFORM);
snprintf (DEOP, sizeof (DEOP), "%s/%s", DAT_DIR, DEFAULT_DEOP);
snprintf (RAND_SAY, sizeof (RAND_SAY), "%s/%s", DAT_DIR, DEFAULT_RAND_SAY);
snprintf (RAND_FILE, sizeof (RAND_FILE), "%s/%s", DAT_DIR, DEFAULT_RAND_FILE);
snprintf (RANDQ_TEMPFILE, sizeof (RANDQ_TEMPFILE), "%s/%s", DAT_DIR, DEFAULT_RANDQ_TEMPFILE);
snprintf (RAND_BACKUP_FILE, sizeof (RAND_BACKUP_FILE), "%s/%s", DAT_DIR, DEFAULT_RAND_BACKUP_FILE);
snprintf (SERVERS, sizeof (SERVERS), "%s/%s", DAT_DIR, DEFAULT_SERVERS);
snprintf (PERMBAN, sizeof (PERMBAN), "%s/%s", DAT_DIR, DEFAULT_PERMBAN);
snprintf (SETUP, sizeof (SETUP), "%s/%s", DAT_DIR, DEFAULT_SETUP);
}
diff --git a/source/random.c b/source/random.c
index 926f473..6623f9e 100644
--- a/source/random.c
+++ b/source/random.c
@@ -1,664 +1,664 @@
#include "defines.h"
#include "vars.h"
#include "prototypes.h"
int get_random_integer(int max)
{
int result;
result = ((float) max) * (rand() / (RAND_MAX + 1.0));
if (result >= max) // Paranoid check.
result = max - 1;
return result;
}
#ifdef ENABLE_RANDOM
void add_randomstuff (char *source, char *target, char *data)
{
char *ptr = NULL;
char file [STRING_LONG] = {0};
size_t nLines = 0;
int ret, toggle = 1;
//#ifndef WIN32
if (BACKUP_RANDOMSTUFF)
{
// Backup randomstuff file to a temporary file.
unlink(RAND_BACKUP_FILE);
snprintf(file, sizeof(file), "cp %s %s\n", RAND_FILE, RAND_BACKUP_FILE);
ret = system(file);
}
//#endif
if(*data == '~')
{
data++;
ptr = strtok(data, " ");
if(ptr != NULL)
strlwr(ptr);
if(strspn(ptr, LEGAL_TEXT) != strlen(ptr))
{
S("privmsg %s :%s, rdb files must be made up of letters and or numbers, no other text is accepted.\n",
target, source);
return;
}
snprintf(file, sizeof(file), "%s/%s.rdb", RDB_DIR, ptr);
data = strtok(NULL, "");
toggle = 0;
}
else
{
snprintf(file, sizeof(file), "%s", RAND_FILE);
nRandStuffs++;
}
db_log(file, "%s\n", data);
nLines = count_lines(file);
L011(target, source, nLines);
}
void get_rand_stuff_time (void)
{
Rand_Stuff = 2 + get_random_integer(RAND_STUFF_TIME);
if (Rand_Stuff < RAND_STUFF_TIME / 2)
Rand_Stuff = RAND_STUFF_TIME;
}
void do_random_stuff (void)
{
FILE *fp = 0;
size_t nLine = 0, nLength = 0, nIndex = 0;
int nIsAction = 0;
char temp [STRING_SHORT] = {0};
char szBuffer [STRING_LONG] = {0};
char *b2 = NULL;
// Count the randomstuffs.
if ((nRandStuffs = count_lines(RAND_FILE)) < 1)
return;
// Get a random line number to display.
nLine = 1 + (size_t) get_random_integer(nRandStuffs);
// If nLine is less than 1, nLine becomes equal to 1
if(nLine < 1)
nLine = 1;
// Complain if we can't open the randomstuff file.
if((fp = fopen(RAND_FILE, "r")) == NULL)
{
S("privmsg %s :Unable to open %s for reading in do_random_stuff()\n",
CHAN, RAND_FILE);
return;
}
while(fgets(szBuffer, STRING_LONG, fp))
{
// Ignore lines that start with a /, treat as comments.
if((*szBuffer != '/') && (*szBuffer != '\n'))
nIndex++;
else
continue;
stripline(szBuffer);
if(nIndex == nLine)
{
nLength = strlen(szBuffer);
nIndex = 0;
memset(data, 0, sizeof(data));
nIsAction = (*szBuffer == '+' ? 1 : 0);
while(nLength > 0)
{
nIndex++;
nLength--;
// Parse data for channel name variable. replace accordingly.
if(szBuffer[nLength] == '~')
snprintf(temp, sizeof(temp), "%s%s", CHAN, data);
else
snprintf(temp, sizeof(temp), "%c%s", szBuffer[nLength], data);
strncpy(data, temp, sizeof(data));
}
// Make sure the file is closed!
fclose (fp);
if(nIsAction == 1)
{
b2 = data;
b2++;
S("privmsg %s :\1ACTION %s\1\n", CHAN, b2);
return;
}
else
{
S("privmsg %s :%s\n", CHAN, data);
return;
}
}
}
fclose(fp);
}
#endif
void do_randomtopic (int type, char *target, char *file, char *nick, char *topic)
{
FILE *fp = 0;
char file2 [FILENAME_MAX] = {0};
char szBuffer2 [STRING_LONG] = {0};
char Data [STRING_LONG] = {0};
char temp [STRING_LONG] = {0};
char crm1 [STRING_LONG] = {0};
char crm2 [STRING_LONG] = {0};
char bFirst = 1;
char *pBuffer = NULL, *ptr = NULL, *pDefault = NULL;
size_t nLength = 0, nRandTopics = 0, nLine = 0,
nIndex = 0;
int toggle = 0, nType = 0, F = 0;
// This ends up being the response, if we're doing a dunno, or whut reply, and the file
// containing the random responses can't be opened.
pDefault = (type == DUNNOR ? DUNNO_Q : WHUT);
if(file != NULL)
snprintf(file2, sizeof(file2), "%s/%s.rdb", RDB_DIR, file);
if ((nRandTopics = count_lines(file2)) < 1)
{
S("privmsg %s :Sorry, I cannot answer that topic because "
"darkbot random text file (rdb) \"%s\" has no lines in it.\n",
target, file2);
return;
}
if ((fp = fopen(file2, "r")) == NULL)
{
// If this is a dunno, or whut response, instead we say our default reply.
if (type == NORMALR)
{
S("privmsg %s :Sorry, I cannot answer that topic because "
"darkbot random text file (rdb) \"%s\" was not found.\n",
target, file2);
}
else
{
S ("privmsg %s :%s\n", target, pDefault);
}
return;
}
/* db_sleep(1) */
// Get line number that we are searching for in the file.
nLine = 1 + (size_t) get_random_integer(nRandTopics);
while(fgets(szBuffer2, STRING_LONG, fp))
{
if((*szBuffer2 != '/') && (*szBuffer2 != '\n'))
nIndex++;
else
continue;
stripline(szBuffer2);
// This is our line!
if(nIndex == nLine)
{
nIndex = 0;
pBuffer = szBuffer2;
/* if ((*pBuffer == '+') || (*pBuffer == '-'))
{
pBuffer++;
nType = ((*pBuffer == '+') ? RDB_ACTION : RDB_RAW);
}
else
nType = RDB_NORMAL;
*/
if (*pBuffer == '+')
{
pBuffer++;
nType = RDB_ACTION;
}
else if (*pBuffer == '-')
{
pBuffer++;
nType = RDB_RAW;
}
else
{
nType = RDB_NORMAL;
}
nLength = (size_t) strlen(pBuffer);
while(nLength > 0)
{
nLength--;
if (toggle == 1)
{
toggle = 0;
// Support for tokens
if (pBuffer[nLength] == '1' || pBuffer[nLength] == '2' || pBuffer[nLength] == '3' ||
pBuffer[nLength] == '4' || pBuffer[nLength] == '5' || pBuffer[nLength] == '6' ||
pBuffer[nLength] == '7' || pBuffer[nLength] == '8' || pBuffer[nLength] == '9')
{
/* The first time around, we just store the topic in a "safe place" */
if (bFirst == 1)
{
strncpy (crm1, topic, sizeof(crm1));
bFirst = 0;
}
/* Each time around, get a new copy from the "safe place". */
strncpy (crm2, crm1, sizeof(crm2));
snprintf (temp, sizeof(temp), "%s%s", get_word (pBuffer[nLength], crm2, "+"), Data);
}
else if(pBuffer[nLength] == 'N')
{ // nick
snprintf(temp, sizeof(temp), "%s%s", nick, Data);
}
else if ((pBuffer[nLength] == 'H') && (*target == '#'))
{ /* u@h of user */
snprintf (temp, sizeof (temp), "%s%s", mask_from_nick (nick, target), Data);
}
else if ((pBuffer[nLength] == 'C') && (*target == '#'))
{ // channel or nick.
snprintf(temp, sizeof(temp), "%s%s", target, Data);
}
else if (pBuffer[nLength] == 'T')
{ // time
snprintf(temp, sizeof(temp), "%s%s", date(), Data);
}
else if (pBuffer[nLength] == 't')
{ /* unixtime */
snprintf (temp, sizeof (temp), "%ld%s", (long) time (NULL), Data);
}
else if ((pBuffer[nLength] == 'R') && (*target == '#'))
{ // Random nick (not if this is not a channel
snprintf(temp, sizeof(temp), "%s%s",
get_rand_nick(target), Data);
}
else if (pBuffer[nLength] == 'S')
{ // Server
snprintf(temp, sizeof(temp), "%s%s", BS, Data);
}
else if (pBuffer[nLength] == 'P')
{ // Port
snprintf(temp, sizeof(temp), "%d%s", (int) BP, Data);
}
else if(pBuffer[nLength] == 'Q')
{ // Question
snprintf(temp, sizeof(temp), "%s%s", revert_topic(topic), Data);
}
else if(pBuffer[nLength] == 'W')
{ // WWW page
- snprintf(temp, sizeof(temp), "http://freezedown.org%s", Data);
+ snprintf(temp, sizeof(temp), "http://darkbot.sourceforge.net%s", Data);
}
else if(pBuffer[nLength] == '!')
{ // cmdchar
snprintf(temp, sizeof(temp), "%c%s", *CMDCHAR, Data);
}
else if(pBuffer[nLength] == 'V')
{ // Version
snprintf(temp, sizeof(temp), "%s%s", dbVersion, Data);
}
else if(pBuffer[nLength] == 'B')
{ // Mynick
snprintf(temp, sizeof(temp), "%s%s", Mynick, Data);
}
else
{
snprintf(temp, sizeof(temp), "%c~%s", pBuffer[nLength], Data);
}
}
else if(pBuffer[nLength] == '~')
{
toggle = 1;
}
else
{
snprintf(temp, sizeof(temp), "%c%s", pBuffer[nLength], Data);
}
strncpy(Data, temp, sizeof(Data));
}
switch (nType)
{
case RDB_ACTION:
S ("privmsg %s :\1ACTION %s\1\n", target, Data);
break;
case RDB_NORMAL:
S ("privmsg %s :%s\n", target, Data);
break;
case RDB_RAW:
ptr = strtok (Data, "|");
while (ptr != NULL)
{
if (ptr[0] == ' ')
ptr++;
if (ptr[0] == 'B' && ptr[1] == 'A' && ptr[2] == 'N')
{ // Ban the user, if the target is a channel.
if (*target == '#')
S ("mode %s +b *%s\n", target, mask_from_nick (nick, target));
else
S ("privmsg %s :Sorry, %s, I can't respond to that topic in private.\n",
target, nick);
}
if (ptr[0] == 'T' && ptr[1] == 'E' && ptr[2] == 'M' && ptr[3] == 'P' &&
ptr[4] == 'B' && ptr[5] == 'A' && ptr[6] == 'N')
{ // Ban user for 60 seconds, if the target is a channel.
if (*target == '#')
{
S ("mode %s +b *%s\n", target, mask_from_nick (nick, target));
snprintf (temp, sizeof (temp), "%s/%ld", DBTIMERS_PATH, (long) time (NULL) + 60);
db_log (temp, "MODE %s -b *%s\n", target, mask_from_nick (nick, target));
}
else
S ("privmsg %s :Sorry, %s, I can't respond to that topic in private.\n",
target, nick);
}
ptr[0] = tolower (ptr[0]);
ptr[1] = tolower (ptr[1]);
if (ptr[0] == 'p' && ptr[1] == 'r')
F = 1;
if (ptr[0] == 'k' && ptr[1] == 'i')
F = 1;
if (ptr[0] == 'n' && ptr[1] == 'o')
F = 1;
if (ptr[0] == 't' && ptr[1] == 'o')
F = 1;
if (F == 1)
{
S ("%s\n", ptr);
F = 0;
}
ptr = strtok (NULL, "|");
}
break;
} // End switch.
fclose (fp);
return;
}
}
fclose(fp);
}
/**
* 05/27/02 Ron
* - Recoded this function, random.ini no longer needs a number
* at the top.
* 6/22/00 Dan
* - Function argument is now pointer to const
* - Fixed a problem where the file was never closed
* - All variables are now initialized when declared
* - Removed an unused variable
* - Changed long variables to type size_t, they should be
* unsigned
* - Changed reinitialization of data
* - Moved the big if/else structure to a switch
*/
char *rand_reply (const char *nick)
{
FILE *fp = 0;
char temp [STRING_SHORT] = {0};
size_t nIndex = 0, nRandTopics = 0, nLine = 0,
nLength = 0;
// Count how many lines are in the RAND_SAY file, if can't be
// counted, just return.
if((nRandTopics = count_lines(RAND_SAY)) < 1)
return(0);
// set nLine to be a random number between 1 and nRandTopics.
nLine = 1 + (size_t) get_random_integer(nRandTopics);
// If the RAND_SAY file can't be opened, just return.
if((fp = fopen(RAND_SAY, "r")) == NULL)
return(0);
while(fgets(r_reply, STRING_SHORT, fp))
{
// Ignore comments
if((*r_reply != '/' ) && (*r_reply != '\n'))
nIndex++;
else
continue;
stripline(r_reply);
if(nIndex != nLine)
continue;
else
{
// This is our line.
fclose(fp);
nLength = (size_t) strlen(r_reply);
nIndex = 0;
data[0] = 0;
while(nLength > 0)
{
nIndex++;
nLength--;
switch(r_reply[nLength])
{
case '^':
snprintf(temp, sizeof(temp), "%s%s", nick, data);
break;
case '%':
snprintf(temp, sizeof(temp), "\2%s", data);
break;
case '&':
snprintf(temp, sizeof(temp), "\37%s", data);
break;
case '~':
snprintf(temp, sizeof(temp), "\26%s", data);
break;
default:
snprintf(temp, sizeof(temp), "%c%s", r_reply[nLength], data);
break;
}
strncpy(data, temp, sizeof(data));
}
// Return our fully parsed line.
return(data);
}
}
// Unable to find a match
fclose(fp);
// A space is returned to prevent crashing
return(" ");
}
#ifdef ENABLE_RANDQ
/*
* do_randq():
*
* Types = RANDQ_NORMAL, RANDQ_CASE, RANDQ_RAND
*/
struct chanserv_output *do_randq(char *text, const int type, const char *target, const char *nick)
{
struct chanserv_output *result = NULL;
FILE *fp = 0;
size_t nLine = 0, length = 0, nNumMatches = 0,
nIndex2 = 0, nIndex3 = 0;
int nIsAction = 0;
char *b2 = NULL;
char temp [STRING_SHORT] = { 0 };
char szBuffer[STRING_LONG] = { 0 };
/*
* Check for RANDQ_RAND, and just do_random_stuff() if it's specified.
*/
if (type == RANDQ_RAND)
{
do_random_stuff ();
return result;
}
if (text == NULL)
{
if(((nNumMatches = count_lines(RAND_FILE)) == -1) || (nNumMatches == 0))
return chanserv_asprintf(NULL, "There are no randomstuffs, or %s cannot be accessed.", RAND_FILE);
result = chanserv_asprintf(result, "there %s %d randomstuff%s",
nNumMatches == 1 ? "is" : "are",
nNumMatches,
nNumMatches == 1 ? "." : "s."
);
return result;
}
/* Remove the temporary file. */
remove(RANDQ_TEMPFILE);
if((fp = fopen(RAND_FILE, "r")) == NULL)
return chanserv_asprintf(result, "I was unable to open %s for reading.", RAND_FILE);
while(!feof(fp))
{
while(fgets(szBuffer, STRING_LONG, fp))
{
if(*szBuffer == '/')
continue;
stripline(szBuffer);
/*
* If type is specified as being case sensitive, use strstr,
* otherwise, use strcasestr
*/
if (type == RANDQ_CASE)
{
if (strstr(szBuffer, text))
{
nNumMatches++;
db_log(RANDQ_TEMPFILE, "%s\n", szBuffer);
}
}
else /* if (type == RANDQ_NORMAL) */
{
if (strcasestr(szBuffer, text) != 0)
{
nNumMatches++;
db_log(RANDQ_TEMPFILE, "%s\n", szBuffer);
}
}
}
}
// Close randomstuff file.
fclose(fp);
// If no matches are present, return that.
if(nNumMatches == 0)
return chanserv_asprintf(result, "I didn't find any matches for your search.");
nLine = 1 + (size_t) get_random_integer(nNumMatches);
// If we can't open the temporary file, complain about it.
if((fp = fopen(RANDQ_TEMPFILE, "r")) == 0)
return chanserv_asprintf(result, "I was unable to open %s for reading.", RANDQ_TEMPFILE);
while(!feof(fp))
{
while(fgets(szBuffer, STRING_LONG, fp))
{
if((*szBuffer != '/' ) || (*szBuffer != '\n'))
nIndex2++;
else
continue;
stripline(szBuffer);
// This is the line we have chosen.
if(nIndex2 == nLine)
{
// Check if this is an action.
nIsAction = (*szBuffer == '+' ? 1 : 0);
length = strlen(szBuffer);
nIndex3 = 0;
memset(data, 0, sizeof(data));
while(length > 0)
{
nIndex3++;
length--;
if(szBuffer[length] == '~')
{
// Replace occurance of this char with chan name
snprintf(temp, sizeof(temp), "%s%s", target, data);
}
else
{
snprintf(temp, sizeof(temp), "%c%s", szBuffer[length], data);
}
strncpy(data, temp, sizeof(data));
}
// Make sure the file is closed.
fclose (fp);
if(nIsAction == 1)
{
b2 = data;
b2++;
return chanserv_asprintf(result, "\1ACTION %s (%d/%d)\1\n", b2, nLine, nNumMatches);
}
else
return chanserv_asprintf(result, "(%d/%d): %s\n", nLine, nNumMatches, data);
}
}
}
fclose(fp);
return result;
}
#endif
diff --git a/source/url.c b/source/url.c
index 89e4048..48795ce 100644
--- a/source/url.c
+++ b/source/url.c
@@ -1,648 +1,648 @@
#include "defines.h"
#include "vars.h"
#include "prototypes.h"
int
check_existing_url (const char *source, char *topic, char *target)
{
FILE *fp;
char b[STRING_LONG] = { 0 }, *subj = NULL;
if ((fp = fopen (URL2, "r")) == NULL)
{
L003 (source, URL2);
return 0;
}
while (fgets (b, STRING_LONG, fp))
{
stripline (b);
subj = strtok (b, " ");
if (strcasecmp (subj, topic) == 0)
{
fclose (fp);
return 1;
}
}
fclose (fp);
return 0;
}
void
find_url (const char *nick, char *topic, char *target)
{
FILE *fp = NULL;
long i = 0, FOUND = 0, x = 0;
char b [STRING_LONG] = {0}, DATA [STRING_SHORT] = {0};
char *subj = NULL, *ptr2 = NULL;
if (strlen (topic) > MAX_TOPIC_SIZE)
topic[MAX_TOPIC_SIZE] = '\0';
strlwr (topic);
if ((fp = fopen (URL2, "r")) == NULL)
{
L003 (nick, URL2);
return;
}
while (fgets (b, STRING_LONG, fp))
{
x++;
if (*b == '\n')
continue; /* Just pass over empty lines */
stripline (b);
subj = strtok (b, " ");
strlwr (subj);
ptr2 = strstr (subj, topic);
if (ptr2 != NULL)
{
i++;
FOUND = 1;
sprintf (DATA, "%s %s", DATA, subj);
if (strlen (DATA) >= MAX_SEARCH_LENGTH)
break;
}
}
fclose (fp);
if (FOUND == 0)
{
L021 (target, NO_TOPIC, topic, x);
}
else if (i > 19)
{
L022 (target, i, DATA);
}
else if (i == 1)
{
L023 (target, nick, DATA);
}
else
L024 (target, i, nick, DATA);
}
struct chanserv_output *display_url (char *target, char *nick, char *topic)
{
struct chanserv_output *result = NULL;
FILE *fp;
long x = 0;
char b[STRING_LONG] = { 0 }, *subj = NULL, *ptr = NULL;
strlwr (topic);
if ((fp = fopen (URL2, "r")) == NULL)
{
result = chanserv_asprintf(result, "there was an error displaying data for \"%s\".", topic);
return result;
}
while (fgets (b, STRING_LONG, fp))
{
x++;
stripline (b);
subj = strtok (b, " ");
ptr = strtok (NULL, "");
if (strcasecmp (subj, topic) == 0 || !match_wild (subj, topic) == 0)
{
QUESTIONS++;
result = chanserv_asprintf(result, "Raw data for %s is: %s", topic, ptr);
fclose (fp);
return result;
} /* Subject match */
}
fclose (fp);
result = chanserv_asprintf(result, "I do not know of any topic named %s\n", topic);
return result;
}
void
delete_url (const char *nick, char *topic, char *target)
{
FILE *fp = 0;
size_t i = 0;
size_t FOUND = 0;
char b [STRING_LONG] = { 0 };
char DATA [STRING_SHORT] = { 0 };
char *subj = NULL;
char *ptr = NULL;
if (*topic == '~')
{
topic++;
if (topic != NULL)
strlwr (topic);
snprintf (DATA, sizeof (DATA), "%s/%s.rdb", RDB_DIR, topic);
if (strspn (topic, LEGAL_TEXT) != strlen (topic))
{
if (strcasecmp (nick, target) == 0)
S ("NOTICE %s :%s, rdb files are made up of letters and or numbers, no other text is accepted.\n", nick, nick);
else
S ("PRIVMSG %s :%s, rdb files are made up of letters and or numbers, no other text is accepted.\n", target, nick);
return;
}
if ((fp = fopen (DATA, "r")) == NULL)
{
if (strcasecmp (nick, target) == 0)
S ("NOTICE %s :%s, %s.rdb does not exist.\n", nick, nick, topic);
else
S ("PRIVMSG %s :%s, %s.rdb does not exist.\n", target, nick, topic);
return;
}
fclose (fp);
remove(DATA);
if (strcasecmp (nick, target) == 0)
S ("NOTICE %s :I have unlinked %s.\n", nick, DATA);
else
S ("PRIVMSG %s :I have unlinked %s.\n", target, DATA);
return;
}
if ((fp = fopen (TMP_URL, "w")) == NULL) /* fixes the 'must have at least 1 topic' problem. */
{
L003 (nick, TMP_URL);
return;
}
fclose (fp);
if ((fp = fopen (URL2, "r")) == NULL)
{
L003 (nick, URL2);
return;
}
while (fgets (b, STRING_LONG, fp))
{
stripline (b);
subj = strtok (b, " ");
ptr = strtok (NULL, "");
i++;
if (strcasecmp (subj, topic) == 0)
{
FOUND = 1;
DELETIONS++;
if (strcasecmp (nick, target) == 0)
L029n (nick, nick, i, topic);
else
L029 (target, nick, i, topic);
}
else if (strstr (subj, " ") == NULL)
db_log (TMP_URL, "%s %s\n", subj, ptr);
}
fclose (fp);
remove(URL2);
rename(TMP_URL, URL2);
if (FOUND == 0)
{
if (strcasecmp (nick, target) == 0)
L030n (nick, nick, topic);
else
L030 (target, nick, topic);
}
}
struct chanserv_output *show_url (char *nick, char *topic, char *target, long donno, long floodpro, char *uh, long no_pipe)
{
struct chanserv_output *result = NULL;
FILE *fp;
long x = 0, length = 0, toggle = 0, A = 0, gotit = 0, D = 0, F = 0, Tog = 0;
char b[STRING_LONG] = { 0 }, *subj = NULL, *ptr = NULL;
char temp[STRING_LONG] = { 0 };
char Data[STRING_LONG] = { 0 }, *ptr8 = NULL;
char crm1[STRING_LONG] = { 0 };
char crm2[STRING_LONG] = { 0 }, bFirst = 1;
strlwr (topic);
/* removes the question mark */
if ((ptr = strchr (topic, '?')) != NULL)
memmove (ptr, ptr + 1, strlen (ptr + 1) + 1);
if ((fp = fopen (URL2, "r")) == NULL)
{
if (donno == 1)
L003 (nick, URL2);
return result;
}
while (fgets (b, STRING_LONG, fp))
{
x++;
stripline (b);
subj = strtok (b, " ");
if (subj == NULL)
continue;
ptr = strtok (NULL, "");
if (ptr == NULL)
continue;
if (strcasecmp (subj, topic) == 0 || !match_wild (subj, topic) == 0)
{
QUESTIONS++;
if (floodpro == 1)
if (cf (uh, nick, nick))
{
fclose (fp);
return result;
}
gotit = 1;
if (*ptr == '+')
{
ptr++;
A = 1;
}
else if (*ptr == '-')
{
if (strstr (nick, "|") != NULL)
return result;
if (no_pipe == 1)
{
fclose (fp);
return result;
}
ptr++;
D = 1;
}
else if (*ptr == '~')
{
ptr++;
fclose (fp);
do_randomtopic (NORMALR, target, ptr, nick, topic);
return result;
}
length = strlen (ptr);
if (length > 3)
{
if (ptr[0] == 'i' && ptr[1] == 'l' && ptr[2] == 'c')
{
toggle++;
}
}
while (length > 0)
{
length--;
if (Tog == 1)
{
Tog = 0;
if (ptr[length] == 'N')
{ /* nick */
toggle++;
snprintf (temp, sizeof (temp), "%s%s", nick, Data);
}
else if (ptr[length] == 'C')
{ /* chan */
toggle++;
snprintf (temp, sizeof (temp), "%s%s", target, Data);
}
else if (ptr[length] == '1'
|| ptr[length] == '2'
|| ptr[length] == '3'
|| ptr[length] == '4'
|| ptr[length] == '5'
|| ptr[length] == '6'
|| ptr[length] == '7' || ptr[length] == '8' || ptr[length] == '9')
{
toggle++;
/* The first time around, we just store the topic in a
"safe place" */
if (bFirst == 1)
{
strncpy (crm1, topic, sizeof (crm1));
bFirst = 0;
}
/* Each time around, get a new copy from the "safe place." */
strncpy (crm2, crm1, sizeof (crm2));
snprintf (temp, sizeof (temp), "%s%s", get_word (ptr[length], crm2, "+"), Data);
}
else if (ptr[length] == 'H')
{ /* u@h of user */
toggle++;
snprintf (temp, sizeof (temp), "%s%s", uh, Data);
}
else if (ptr[length] == 'h')
{ /* u@h (no ident) */
toggle++;
if (*uh == '~')
{
uh++;
}
snprintf (temp, sizeof (temp), "%s%s", uh, Data);
}
else if (ptr[length] == 'T')
{ /* time */
toggle++;
snprintf (temp, sizeof (temp), "%s%s", date (), Data);
}
else if (ptr[length] == 't')
{ /* unixtime */
toggle++;
snprintf (temp, sizeof (temp), "%ld%s", (long)time (NULL), Data);
}
else if (ptr[length] == 'W')
{ /* WWW page */
toggle++;
- snprintf (temp, sizeof (temp), "http://freezedown.org%s", Data);
+ snprintf (temp, sizeof (temp), "http://darkbot.sourceforge.net%s", Data);
}
else if (ptr[length] == 'S')
{ /* server */
toggle++;
snprintf (temp, sizeof (temp), "%s%s", BS, Data);
}
else if (ptr[length] == 'R')
{ /* rand */
toggle++;
/* The first time around, we just store the topic in a
"safe place" */
if (bFirst == 1)
{
strncpy (crm1, topic, sizeof (crm1));
bFirst = 0;
}
// Don't do random nicknames if the target isn't a channel!!
snprintf (temp, sizeof (temp), "%s%s",
((*target != '#') ? "R~" : get_rand_nick (target)),
Data);
}
else if (ptr[length] == 'P')
{ /* port */
toggle++;
snprintf (temp, sizeof (temp), "%ld%s", BP, Data);
}
else if (ptr[length] == 'Q')
{ /* question */
toggle++;
snprintf (temp, sizeof (temp), "%s%s", revert_topic (topic), Data);
}
else if (ptr[length] == 'V')
{ /* version */
toggle++;
snprintf (temp, sizeof (temp), "%s%s", dbVersion, Data);
}
else if (ptr[length] == '!')
{ /* cmdchar */
toggle++;
snprintf (temp, sizeof (temp), "%c%s", *CMDCHAR, Data);
}
else if (ptr[length] == 'B')
{ /* mynick */
toggle++;
snprintf (temp, sizeof (temp), "%s%s", Mynick, Data);
}
else
snprintf (temp, sizeof (temp), "%c~%s", ptr[length], Data);
}
else if (ptr[length] == '~')
{
Tog = 1;
}
else
snprintf (temp, sizeof (temp), "%c%s", ptr[length], Data);
strncpy (Data, temp, sizeof (Data));
} /* While */
if (D == 1)
{
ptr8 = strtok (Data, "|");
while (ptr8 != NULL)
{
if (ptr8[0] == ' ')
ptr8++;
if (ptr8[0] == 'B' && ptr8[1] == 'A' && ptr8[2] == 'N')
{ /* ban user */
S ("MODE %s +b *%s\n", target, uh);
}
if (ptr8[0] == 'T' && ptr8[1] == 'E' && ptr8[2] == 'M' &&
ptr8[3] == 'P' && ptr8[4] == 'B' && ptr8[5] == 'A' && ptr8[6] == 'N')
{ /* temp ban user for 60 sec */
S ("MODE %s +b *%s\n", target, uh);
snprintf (temp, sizeof (temp), "%s/%ld", DBTIMERS_PATH, (long)time (NULL) + 60);
db_log (temp, "MODE %s -b *%s\n", target, uh);
}
ptr8[0] = tolower (ptr8[0]);
ptr8[1] = tolower (ptr8[1]);
if (ptr8[0] == 'p' && ptr8[1] == 'r')
F = 1;
if (ptr8[0] == 'k' && ptr8[1] == 'i' && !is_op(nick, target))
F = 1;
if (ptr8[0] == 'n' && ptr8[1] == 'o')
F = 1;
if (ptr8[0] == 't' && ptr8[1] == 'o')
F = 1;
if (F == 1)
S ("%s\n", ptr8);
F = 0;
ptr8 = strtok (NULL, "|");
}
fclose (fp);
return result;
}
// TODO - It's entirely possible that some of these need to be targeted to NOTICE / PRIVMSG.
if (toggle == 0)
{
#ifdef ENABLE_STATS
add_stats (nick, uh, 1, time (NULL), time (NULL));
#endif
if (A == 0)
{
if ((*target == '#') || (*target == '+') || (*target == '&'))
result = chanserv_asprintf(result, "%s%s", rand_reply (nick), Data);
else
{
result = chanserv_asprintf(result, "%s%s", rand_reply(target), temp, Data);
}
}
else if ((*target == '#') || (*target == '+') || (*target == '&'))
result = chanserv_asprintf(result, "\1ACTION %s\1", Data);
else
{
result = chanserv_asprintf(result, "%s%s", rand_reply(target), Data);
}
}
else if (A == 0)
{
#ifdef ENABLE_STATS
add_stats (nick, uh, 1, time (NULL), time (NULL));
#endif
if ((*target == '#') || (*target == '+') || (*target == '&'))
result = chanserv_asprintf(result, Data);
else
{
result = chanserv_asprintf(result, Data);
}
}
else if ((*target == '#') || (*target == '+') || (*target == '&'))
{
#ifdef ENABLE_STATS
add_stats (nick, uh, 1, time (NULL), time (NULL));
#endif
result = chanserv_asprintf(result, "\1ACTION %s\1\n", Data);
}
else if (MSG_RESPONSES)
{
#ifdef ENABLE_STATS
add_stats (nick, uh, 1, time (NULL), time (NULL));
#endif
result = chanserv_asprintf(result, Data);
}
fclose (fp);
return result;
} /* Subject match */
}
fclose (fp);
if (donno == 1)
{
if (strlen (topic) > 3)
{
strlwr (topic);
if (topic[0] == 'i' && topic[1] == 'l' && topic[2] == 'c')
{
if ((*target == '#') || (*target == '+') || (*target == '&'))
result = chanserv_asprintf(result, "I found no matching ILC for that channel.");
return result;
}
}
if ((*target == '#') || (*target == '+') || (*target == '&'))
{
if (RANDOM_DUNNO == true)
do_randomtopic (DUNNOR, target, DUNNO_FILE, nick, topic);
else
result = chanserv_asprintf(result, DUNNO_Q);
}
else
result = chanserv_asprintf(result, DUNNO_Q);
}
return result;
}
char *
get_multiword_topic (char *first)
{
char *tmp2 = NULL;
tmp2 = strtok (NULL, " ");
if (tmp2 != NULL)
{
sprintf (f_tmp, "%s", first);
while (tmp2 != NULL)
{
sprintf (f_tmp, "%s+%s", f_tmp, tmp2);
tmp2 = strtok (NULL, " ");
}
return f_tmp;
}
else
return first;
}
void
datasearch (const char *nick, char *topic, char *target)
{
FILE *fp = NULL;
size_t i = 0, FOUND = 0, x = 0;
char b[STRING_LONG] = { 0 }, *dorf = NULL, *subj = NULL, *ptr2 = NULL, DATA[STRING_SHORT] =
{
0};
/* Make sure topic is not NULL.*/
if (topic == NULL)
{
return;
}
if (strlen (topic) > MAX_TOPIC_SIZE)
topic[MAX_TOPIC_SIZE] = '\0';
strlwr (topic);
if ((fp = fopen (URL2, "r")) == NULL)
{
L003 (nick, URL2);
return;
}
while (fgets (b, STRING_LONG, fp))
{
x++;
if (*b == '\n')
continue; /* Just pass over blank lines */
stripline (b);
strlwr (b);
subj = strtok (b, " ");
dorf = strtok (NULL, "");
ptr2 = strstr (dorf, topic);
if (ptr2 != NULL)
{
i++;
FOUND = 1;
sprintf (DATA, "%s %s", DATA, subj);
if (strlen (DATA) >= MAX_SEARCH_LENGTH)
break;
}
}
fclose (fp);
if (FOUND == 0)
{
L021 (target, NO_TOPIC, topic, x);
}
else if (i > 19)
{
L022 (target, i, DATA);
}
else if (i == 1)
{
L023 (target, nick, DATA);
}
else
L024 (target, i, nick, DATA);
}
char *
get_word (long number, char *string, char *seperator)
{ /* gets a specific word requested */
long i = 0;
char *ptr = NULL;
number = number - 49;
ptr = strtok (string, "+");
strncpy (f_tmp, ptr, sizeof (f_tmp));
if (ptr != NULL)
{
while (ptr != NULL)
{
i++; /* word number */
ptr = strtok (NULL, seperator);
if (ptr != NULL)
{
if (i == number)
{
snprintf (f_tmp, sizeof (f_tmp), "%s", ptr);
return f_tmp;
}
}
}
return f_tmp;
}
else
{ /* only one word */
if (number == 1)
{
return f_tmp;
}
else
return ""; /* no match */
}
}
diff --git a/source/vars.c b/source/vars.c
index 19fd1d6..f015731 100644
--- a/source/vars.c
+++ b/source/vars.c
@@ -1,468 +1,468 @@
#include "defines.h"
#include "vars.h"
#include "prototypes.h"
int wsock = 0;
int sockerr = 0;
int optlen = sizeof(sockerr);
size_t nRandStuffs = 0;
long QUESTIONS = 0;
long ADDITIONS = 0;
long DELETIONS = 0;
long uptime = 0;
long NO_FLOOD = 0;
long NUM_SERV = 0;
long L_CLIENTS = 0;
long IRCOPS = 0;
long xtried = 0;
long G_USERS = 0;
long rt = 120;
long fc = 0;
long spr = 0;
long snr = 0;
long BP = 6667;
long CHECKED = 1;
long SEND_DELAY = 1;
long send_tog = 0;
long NUM_HELPER = 0;
long NUMLINESSEEN = 0;
long NUM_USER = 0;
#ifdef ENABLE_QUIZ
long quiz_timer = 0;
long quiz_line = 0;
bool quiz_answer = 0;
bool quiz_halt = 0;
char quiz_target[STRING_SHORT] = { 0 };
long recent_questions[10] = { 0 };
#endif
#ifdef ENABLE_RANDOM
long Rand_Stuff = 0;
long Rand_Idle = 0;
#endif
long AIL4 = 0;
long Sleep_Toggle = 0;
long Sleep_Time = 0;
long AIL3 = 0;
long AIL2 = 0;
long AIL5 = 0;
long JOINs = 0;
long PERMBAN_counter = 0;
long ram_load_time = 0;
long AIL9 = 0;
long AIL666 = 0;
long AIL8 = 0;
#ifdef ENABLE_QUIZ
long AIL13 = 0;
#endif
long LastInput = 0;
long AIL10 = 0;
long MARK_CHANGE = 0;
long html_counter = 0;
char NICK_COMMA[32] = { 0 };
char COLON_NICK[33] = { 0 };
char pass_data[512] = { 0 };
char pass_pass[STRING_SHORT] = { 0 };
char rword[STRING_SHORT] = { 0 };
char lc1[STRING_SHORT] = "0";
char lc2[STRING_SHORT] = "0";
char lc4[STRING_SHORT] = "0";
char lc3[STRING_SHORT] = "0";
char BPASS[STRING_SHORT] = "0";
char mask_tmp[STRING_LONG] = "0";
long lcn1 = 0;
long lcn2 = 0;
long lcn4 = 0;
long lcn3 = 0;
bool SeeN = false;
long DebuG = 0;
char slc1[STRING_SHORT] = "0";
char slc2[STRING_SHORT] = "0";
char slc4[STRING_SHORT] = "0";
char slc3[STRING_SHORT] = "0";
long slcn1 = 0;
long slcn2 = 0;
long slcn4 = 0;
long slcn3 = 0;
#ifdef WIN32
char *rp391 = "niW-4cr8 tobkraD";
#else
char *rp391 = "4cr8 tobkraD";
#endif
char BCOLON_NICK[STRING_SHORT] = { 0 };
char DARKBOT_BIN[STRING_SHORT] = { 0 };
char URL2[STRING_SHORT] = { 0 };
char DBTIMERS_PATH[STRING_SHORT] = { 0 };
char LOG_DIR[STRING_SHORT] = { 0 };
char RDB_DIR[STRING_SHORT] = { 0 };
#ifdef ENABLE_STATS
char STATS_FILE[STRING_SHORT] = { 0 };
#endif
char SEEN_FILE[STRING_SHORT] = { 0 };
char BACKUP_DUP[STRING_SHORT] = { 0 };
char ADD_DELETES[STRING_SHORT] = { 0 };
char AUTOTOPIC_F[STRING_SHORT] = { 0 };
char HELPER_LIST[STRING_SHORT] = { 0 };
char QUIZ_FILE[STRING_SHORT] = { 0 };
char PERFORM[STRING_SHORT] = { 0 };
char DEOP[STRING_SHORT] = { 0 };
char RAND_SAY[STRING_SHORT] = { 0 };
char RAND_FILE[STRING_SHORT] = { 0 };
char RANDQ_TEMPFILE[STRING_SHORT] = { 0 };
char RAND_BACKUP_FILE[STRING_SHORT] = { 0 };
char SERVERS[STRING_SHORT] = { 0 };
char PERMBAN[STRING_SHORT] = { 0 };
char SETUP[STRING_SHORT] = { 0 };
char DAT_DIR[STRING_SHORT] = { 0 };
char r_reply[STRING_SHORT] = { 0 };
char data[STRING_SHORT] = { 0 };
char g_chan[STRING_SHORT] = { 0 };
char dbVersion[STRING_SHORT] = { 0 };
char strbuff[STRING_SHORT] = { 0 };
char f_tmp[STRING_LONG] = { 0 };
char UID[STRING_SHORT] = "database";
-char BS[STRING_SHORT] = "irc.undernet.org";
+char BS[STRING_SHORT] = "irc.freenode.net";
char CMDCHAR[2] = "!";
char CHAN[STRING_SHORT] = "#darkbot";
char s_Mynick[STRING_SHORT] = "darkbot";
char g_host[STRING_SHORT] = { 0 };
char Mynick[STRING_SHORT] = "darkbot";
char sleep_chan[STRING_SHORT] = { 0 };
char VHOST[STRING_SHORT] = "0";
-char REALNAME[STRING_SHORT] = "http://www.freezedown.org";
+char REALNAME[STRING_SHORT] = "http://darkbot.sourceforge.net";
char privmsg_log[STRING_SHORT] = { 0 };
long CONNECT_WAIT_TIMEOUT = 10;
bool PERFORM_TIMER = true;
char DEFAULT_UMODE[STRING_SHORT] = "+i-ds";
bool ANTI_IDLE = false;
bool DISPLAY_SYNC = false;
bool SORT = false;
bool FIND_DUPS = false;
bool SAVE_DUPS = true;
bool GENERAL_QUESTIONS = true;
//bool ALLOW_ADD_IN_MSG = false;
//bool ALLOW_DEL_IN_MSG = false;
bool MSG_RESPONSES = false;
bool LOG_ADD_DELETES = true;
bool LOG_PRIVMSG = true;
long SLEEP_TIME = 300;
char GOSLEEP_ACTION[STRING_SHORT] = "\1ACTION falls asleep... ZzzZZzzZZzz\1";
char WAKEUP_ACTION[STRING_SHORT] = "\1ACTION wakes up from a snooze..\1";
long LASTCOMM_TIME = 5;
long OUTPUT1_COUNT = 4;
long OUTPUT1_DELAY = 1;
long OUTPUT2_COUNT = 6;
long OUTPUT2_DELAY = 2;
long OUTPUT3_DELAY = 3;
long OUTPUT_PURGE_COUNT = 7;
char EXISTING_ENTRY[STRING_SHORT] = "Sorry, there is an existing entry under keyword";
char NO_ENTRY[STRING_SHORT] = "I was unable to find entry:";
//char CANT_FIND[STRING_SHORT] = "Was unable to find"; /* ... */
char NO_TOPIC[STRING_SHORT] = "Sorry, I don't have any entry for"; /* ... */
char TRY_FIND[STRING_SHORT] = "What am I trying to find";
char WHUT[STRING_SHORT] = "hmmm?";
char DUNNO_Q[STRING_SHORT] = "*shrug*";
bool RANDOM_DUNNO = true;
bool RANDOM_WHUT = true;
#ifdef ENABLE_RANDOM
//bool RANDOM_STUFF = true;
long RAND_STUFF_TIME = 3600;
long RAND_IDLE = 1800;
//long RAND_LEVEL = 2;
//bool RANDQ = true;
bool BACKUP_RANDOMSTUFF = false;
#endif
bool JOIN_GREET = true;
long SLASTCOMM_TIME = 60;
bool VOICE_USERS_ON_JOIN = false;
bool OP_USERS_ON_LOGIN = false;
bool DO_WHOIS = false;
long MAX_LASTSEEN = 604800;
char SEEN_REPLY[STRING_SHORT] = "in the last 7 days.";
char COMPLAIN_REASON[STRING_SHORT] = "grrr, kick me again and I'm going to...";
bool BITCH_ABOUT_DEOP = false;
char BITCH_DEOP_REASON[STRING_SHORT] = "grr, someone op me!";
long AUTOTOPIC_TIME = 1800;
char DEFAULT_KICK[STRING_SHORT] = "Requested!";
bool KICK_ON_BAN = false;
bool KICK_ON_CHANNEL_NOTICE = true;
bool BAN_ON_CHANNEL_NOTICE = false;
bool BAN_BY_HOST = false;
bool FLOOD_KICK = true;
char FLOOD_REASON[STRING_SHORT] = "Don't flood!";
#ifdef ENABLE_QUIZ
long QUIZ_TIMER = 25;
long QUIZ_REPEAT_TIMER = 20;
#endif
bool HELP_GREET = false;
bool AUTOHELP_GUESTS = false;
char mySetinfo[STRING_SHORT] = "My !setinfo variables are: ^ nick, % Number of joins, & \
Channel, $ user@host. Example: !setinfo ^ has joined & % times!! (also, if \
you make the first char of your SETINFO a \"+\" the setinfo will be shown \
as an ACTION)";
char myVariables[STRING_SHORT] = "Data variables are: N~ (Nick), C~ (Chan), T~ \
(Time/date) B~ (Botnick), Q~ (Question asked), R~ (random nick), !~ \
(command char), S~ (current Server), P~ (current port) V~ (botVer), W~ \
(db WWW site), H~ (u@h), t~ (unixtime), BAN (sets a ban), TEMPBAN (bans \
for 60 sec)";
struct rusage r_usage;
struct ignorelist *ignorehead = NULL;
struct sendq *sendqhead = NULL, *sendqtail = NULL;
struct userlist *userhead = NULL;
struct helperlist *helperhead = NULL;
struct permbanlist *permbanhead = NULL;
struct old ood[STRING_SHORT];
struct sl124 *sh124 = NULL;
#ifdef ENABLE_STATS
struct statslist *statshead = NULL;
#endif
struct webinfo
WEBSEARCH_webinfo = { "WEBSEARCH", "api.duckduckgo.com", 80, "/?format=xml&q=" } ,
METAR_webinfo = { "METAR", "www.aviationweather.gov", 80, "/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=" } ,
TAF_webinfo = { "TAF", "www.aviationweather.gov", 80, "/adds/dataserver_current/httpparam?dataSource=tafs&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=" } ,
WEATHER_webinfo = { "WEATHER", "mobile.wunderground.com", 80, "/cgi-bin/findweather/getForecast?brand=mobile&query=" };
struct setup_parameter parameters[] =
{
// I managed to eliminate these options when I rewrote chansrv.c.
// {ST_BOOLEAN, 3, sizeof(ALLOW_ADD_IN_MSG), {"ALLOW_ADD_IN_MSG", NULL, NULL, NULL, NULL}, "allowing ADD command in private", &ALLOW_ADD_IN_MSG, NULL},
// {ST_BOOLEAN, 3, sizeof(ALLOW_DEL_IN_MSG), {"ALLOW_DEL_IN_MSG", NULL, NULL, NULL, NULL}, "allowing DEL command in private", &ALLOW_DEL_IN_MSG, NULL},
{ST_BOOLEAN, 3, sizeof(ANTI_IDLE), {"ANTI_IDLE", NULL, NULL, NULL, NULL}, "idling for less than ten minutes", &ANTI_IDLE, NULL},
#ifdef ENABLE_CHANNEL
{ST_BOOLEAN, 3, sizeof(BITCH_ABOUT_DEOP), {"BITCH_DEOP", NULL, NULL, NULL, NULL}, "bitch about deop", &BITCH_ABOUT_DEOP, NULL},
{ST_STRING, 3, sizeof(BITCH_DEOP_REASON), {"BITCH_DEOP_TEXT", NULL, NULL, NULL, NULL}, "deop complaint", BITCH_DEOP_REASON, NULL},
#endif
{ST_STRING, 3, sizeof(COMPLAIN_REASON), {"BITCH_KICK_TEXT", NULL, NULL, NULL, NULL}, "bot kicked message", COMPLAIN_REASON, NULL},
{ST_STRING, 3, sizeof(CMDCHAR), {"BOT_CMD_CHAR", NULL, NULL, NULL, NULL}, "bot's command char", CMDCHAR, NULL},
{ST_STRING, 3, sizeof(Mynick), {"BOT_NICK", NULL, NULL, NULL, NULL}, "bot's nickname", Mynick, check_nick_parameter},
{ST_STRING, 3, sizeof(REALNAME), {"BOT_NAME", NULL, NULL, NULL, NULL}, "bot's real name", REALNAME, NULL},
{ST_STRING, 3, sizeof(UID), {"BOT_USER_ID", NULL, NULL, NULL, NULL}, "bot's user ID", UID, NULL},
{ST_STRING, 3, sizeof(DEFAULT_UMODE), {"BOT_USER_MODE", NULL, NULL, NULL, NULL}, "bot's user modes", DEFAULT_UMODE, NULL},
{ST_STRING, 3, sizeof(VHOST), {"BOT_VHOST", NULL, NULL, NULL, NULL}, "bot's virtual host", VHOST, NULL},
{ST_INTEGER, 3, sizeof(CONNECT_WAIT_TIMEOUT), {"CONNECT_TIME", NULL, NULL, NULL, NULL}, "server connection timeout", &CONNECT_WAIT_TIMEOUT, NULL},
{ST_STRING, 3, sizeof(CHAN), {"DEFAULT_CHANNEL", NULL, NULL, NULL, NULL}, "channel", CHAN, NULL},
{ST_BOOLEAN, 3, sizeof(DISPLAY_SYNC), {"DISPLAY_SYNC", NULL, NULL, NULL, NULL}, "tell channel bot has finished syncing", &DISPLAY_SYNC, NULL},
{ST_BOOLEAN, 3, sizeof(DO_WHOIS), {"DO_WHOIS", NULL, NULL, NULL, NULL}, "questionable channel alert", &DO_WHOIS, NULL},
{ST_STRING, 3, sizeof(DUNNO_Q), {"DUNNO_TEXT", NULL, NULL, NULL, NULL}, "no answer complaint", DUNNO_Q, NULL},
{ST_BOOLEAN, 3, sizeof(RANDOM_DUNNO), {"DUNNO_RANDOM_TEXT", NULL, NULL, NULL, NULL}, "random no answer complaint", &RANDOM_DUNNO, NULL},
{ST_BOOLEAN, 3, sizeof(FIND_DUPS), {"DUPS_REMOVE", NULL, NULL, NULL, NULL}, "remove duplicates in hatabase", &FIND_DUPS, NULL},
{ST_BOOLEAN, 3, sizeof(SAVE_DUPS), {"DUPS_SAVE", NULL, NULL, NULL, NULL}, "save duplicates in database", &SAVE_DUPS, NULL},
{ST_STRING, 3, sizeof(EXISTING_ENTRY), {"ENTRY_EXISTS_TEXT", NULL, NULL, NULL, NULL}, "replacing existing complaint", EXISTING_ENTRY, NULL},
{ST_STRING, 3, sizeof(NO_ENTRY), {"ENTRY_NOT_EXIST_TEXT", NULL, NULL, NULL, NULL}, "non-existing topic complaint", NO_ENTRY, NULL},
{ST_STRING, 3, sizeof(NO_TOPIC), {"FIND_NO_TEXT", NULL, NULL, NULL, NULL}, "no topic search complaint", NO_TOPIC, NULL},
{ST_STRING, 3, sizeof(TRY_FIND), {"FIND_WHAT_TEXT", NULL, NULL, NULL, NULL}, "try find search complaint", TRY_FIND, NULL},
#ifdef ENABLE_CHANNEL
{ST_BOOLEAN, 3, sizeof(KICK_ON_CHANNEL_NOTICE), {"FLOOD_NOTICE_KICK", NULL, NULL, NULL, NULL}, "kick on channel notice flood", &KICK_ON_CHANNEL_NOTICE, NULL},
{ST_BOOLEAN, 3, sizeof(BAN_ON_CHANNEL_NOTICE), {"FLOOD_NOTICE_BAN", NULL, NULL, NULL, NULL}, "ban on channel notice flood", &BAN_ON_CHANNEL_NOTICE, NULL},
{ST_BOOLEAN, 3, sizeof(BAN_BY_HOST), {"FLOOD_NOTICE_BAN_HOST", NULL, NULL, NULL, NULL}, "ban by host on channel notice flood", &BAN_BY_HOST, NULL},
{ST_BOOLEAN, 3, sizeof(FLOOD_KICK), {"FLOOD_KICK", NULL, NULL, NULL, NULL}, "kick if bot is flooded", &FLOOD_KICK, NULL},
{ST_STRING, 3, sizeof(FLOOD_REASON), {"FLOOD_TEXT", NULL, NULL, NULL, NULL}, "flooded bot complaint", FLOOD_REASON, NULL},
#endif
{ST_BOOLEAN, 3, sizeof(AUTOHELP_GUESTS), {"GREET_GUESTS_TEXT", NULL, NULL, NULL, NULL}, "give guests help", &AUTOHELP_GUESTS, NULL},
{ST_BOOLEAN, 3, sizeof(HELP_GREET), {"GREET_NEW_TEXT", NULL, NULL, NULL, NULL}, "give new users help", &HELP_GREET, NULL},
{ST_BOOLEAN, 3, sizeof(JOIN_GREET), {"GREET_USER_TEXT", NULL, NULL, NULL, NULL}, "registered user greeting", &JOIN_GREET, NULL},
{ST_INTEGER, 3, sizeof(LASTCOMM_TIME), {"IGNORE_TIME", NULL, NULL, NULL, NULL}, "seconds to ignore repeated topics", &LASTCOMM_TIME, NULL},
{ST_INTEGER, 3, sizeof(SLASTCOMM_TIME), {"IGNORE_USER_TIME", NULL, NULL, NULL, NULL}, "registered user delay seconds", &SLASTCOMM_TIME, NULL},
#ifdef ENABLE_CHANNEL
{ST_STRING, 3, sizeof(DEFAULT_KICK), {"KICK_TEXT", NULL, NULL, NULL, NULL}, "kick message", DEFAULT_KICK, NULL},
{ST_BOOLEAN, 3, sizeof(KICK_ON_BAN), {"KICK_ON_BAN", NULL, NULL, NULL, NULL}, "kick when banned", &KICK_ON_BAN, NULL},
#endif
{ST_BOOLEAN, 3, sizeof(LOG_ADD_DELETES), {"LOG_CHANGES", NULL, NULL, NULL, NULL}, "logging of database changes", &LOG_ADD_DELETES, NULL},
{ST_BOOLEAN, 3, sizeof(LOG_PRIVMSG), {"LOG_PRIVATE", NULL, NULL, NULL, NULL}, "logging of private messages", &LOG_PRIVMSG, NULL},
#ifdef ENABLE_CHANNEL
{ST_BOOLEAN, 3, sizeof(OP_USERS_ON_LOGIN), {"OP_ON_LOGIN", NULL, NULL, NULL, NULL}, "op users on login", &OP_USERS_ON_LOGIN, NULL},
#endif
{ST_INTEGER, 3, sizeof(OUTPUT1_COUNT), {"OUTPUT1_COUNT", NULL, NULL, NULL, NULL}, "output delay threshold", &OUTPUT1_COUNT, NULL},
{ST_INTEGER, 3, sizeof(OUTPUT1_DELAY), {"OUTPUT1_TIME", NULL, NULL, NULL, NULL}, "output delay seconds", &OUTPUT1_DELAY, NULL},
{ST_INTEGER, 3, sizeof(OUTPUT2_COUNT), {"OUTPUT2_COUNT", NULL, NULL, NULL, NULL}, "long output delay threshold", &OUTPUT2_COUNT, NULL},
{ST_INTEGER, 3, sizeof(OUTPUT2_DELAY), {"OUTPUT2_TIME", NULL, NULL, NULL, NULL}, "long output delay seconds", &OUTPUT2_DELAY, NULL},
{ST_INTEGER, 3, sizeof(OUTPUT_PURGE_COUNT), {"OUTPUT_PURGE_COUNT", NULL, NULL, NULL, NULL}, "purge output delay threshold", &OUTPUT_PURGE_COUNT, NULL},
{ST_INTEGER, 3, sizeof(OUTPUT3_DELAY), {"OUTPUT3_TIME", NULL, NULL, NULL, NULL}, "purge output delay seconds", &OUTPUT3_DELAY, NULL},
{ST_BOOLEAN, 3, sizeof(PERFORM_TIMER), {"PERFORM_TIME", NULL, NULL, NULL, NULL}, "sending perform.ini to server reqularly", &PERFORM_TIMER, NULL},
{ST_BOOLEAN, 3, sizeof(GENERAL_QUESTIONS), {"QUESTIONS_GENERAL", NULL, NULL, NULL, NULL}, "bot responds without being asked", &GENERAL_QUESTIONS, NULL},
{ST_BOOLEAN, 3, sizeof(MSG_RESPONSES), {"QUESTIONS_PRIVATE", NULL, NULL, NULL, NULL}, "bot responds to private questions", &MSG_RESPONSES, NULL},
#ifdef ENABLE_QUIZ
{ST_INTEGER, 3, sizeof(QUIZ_TIMER), {"QUIZ_TIME", NULL, NULL, NULL, NULL}, "quiz answer seconds", &QUIZ_TIMER, NULL},
{ST_INTEGER, 3, sizeof(QUIZ_REPEAT_TIMER), {"QUIZ_REPEAT_TIME", NULL, NULL, NULL, NULL}, "next quiz delay seconds", &QUIZ_REPEAT_TIMER, NULL},
#endif
#ifdef ENABLE_RANDOM
// This one is currently ./configure --enable-random
// {ST_BOOLEAN, 3, sizeof(RANDOM_STUFF), {"RANDOM_STUFF", NULL, NULL, NULL, NULL}, "random utterences", &RANDOM_STUFF, NULL},
{ST_BOOLEAN, 3, sizeof(BACKUP_RANDOMSTUFF), {"RANDOM_BACKUP", NULL, NULL, NULL, NULL}, "enable random stuff auto backups", &BACKUP_RANDOMSTUFF, NULL},
{ST_INTEGER, 3, sizeof(RAND_IDLE), {"RANDOM_IDLE_TIME", NULL, NULL, NULL, NULL}, "seconds idle before random utterences", &RAND_IDLE, NULL},
// This one is currently ./configure --with-random=level
// {ST_INTEGER, 3, sizeof(RAND_LEVEL), {"RANDOM_LEVEL", NULL, NULL, NULL, NULL}, "level for adding random things", &RAND_LEVEL, NULL},
// This one is currently ./configure --enable-randq
// {ST_BOOLEAN, 3, sizeof(RANDQ), {"RANDOM_Q", NULL, NULL, NULL, NULL}, "enable RANDQ command", &RANDQ, NULL},
{ST_INTEGER, 3, sizeof(RAND_STUFF_TIME), {"RANDOM_TIME", NULL, NULL, NULL, NULL}, "seconds between random utterences", &RAND_STUFF_TIME, NULL},
#endif
{ST_BOOLEAN, 3, sizeof(SeeN), {"SEEN_MODE", NULL, NULL, NULL, NULL}, "seen mode", &SeeN, NULL},
{ST_INTEGER, 3, sizeof(MAX_LASTSEEN), {"SEEN_TIME", NULL, NULL, NULL, NULL}, "maximum last seen seconds", &MAX_LASTSEEN, NULL},
{ST_STRING, 3, sizeof(SEEN_REPLY), {"SEEN_TEXT", NULL, NULL, NULL, NULL}, "maximum last seen reply", SEEN_REPLY, NULL},
{ST_STRING, 3, sizeof(mySetinfo), {"SETINFO_TEXT", NULL, NULL, NULL, NULL}, "setinfo variables help text", mySetinfo, NULL},
{ST_INTEGER, 3, sizeof(SLEEP_TIME), {"SLEEP_TIME", NULL, NULL, NULL, NULL}, "seconds to sleep for", &SLEEP_TIME, NULL},
{ST_STRING, 3, sizeof(GOSLEEP_ACTION), {"SLEEP_TEXT", NULL, NULL, NULL, NULL}, "sleep action", GOSLEEP_ACTION, NULL},
{ST_STRING, 3, sizeof(WAKEUP_ACTION), {"SLEEP_WAKE_TEXT", NULL, NULL, NULL, NULL}, "wakeup action", WAKEUP_ACTION, NULL},
{ST_BOOLEAN, 3, sizeof(SORT), {"SORT_DB", NULL, NULL, NULL, NULL}, "sort database on startup", &SORT, NULL},
#ifdef ENABLE_CHANNEL
{ST_INTEGER, 3, sizeof(AUTOTOPIC_TIME), {"TOPIC_TIME", NULL, NULL, NULL, NULL}, "topic setting seconds", &AUTOTOPIC_TIME, NULL},
#endif
{ST_STRING, 3, sizeof(myVariables), {"VARIABLES_TEXT", NULL, NULL, NULL, NULL}, "data variables help text", myVariables, NULL},
#ifdef ENABLE_CHANNEL
{ST_BOOLEAN, 3, sizeof(VOICE_USERS_ON_JOIN), {"VOICE_ON_JOIN", NULL, NULL, NULL, NULL}, "voice users on join", &VOICE_USERS_ON_JOIN, NULL},
#endif
{ST_STRING, 3, sizeof(WHUT), {"WHUT_TEXT", NULL, NULL, NULL, NULL}, "no text complaint", WHUT, NULL},
{ST_BOOLEAN, 3, sizeof(RANDOM_WHUT), {"WHUT_RANDOM_TEXT", NULL, NULL, NULL, NULL}, "random no text complaint", &RANDOM_WHUT, NULL},
// Cant find CANT_FIND. B-)
// {ST_STRING, 3, sizeof(CANT_FIND), {"CANT_FIND", NULL, NULL, NULL, NULL}, "can't find search complaint", CANT_FIND, NULL},
{ST_STRING, 4, 0, {NULL, NULL, NULL, NULL, NULL}, NULL, NULL, NULL}
};
struct setup_parameter *
set_parameter(char *input)
{
struct setup_parameter *result = NULL;
/* ignore comments. */
if (*input != '#')
{
int i, found = -1;
char *dat = NULL, *ptr = NULL;
dat = strdup(input);
if ((ptr = strchr(dat, '=')) != NULL)
*ptr++ = '\0';
for (result = &parameters[0]; result->parameter[0] != NULL; result++)
{
for (i = 0; result->parameter[i] != NULL; i++)
{
if (strcasecmp(dat, result->parameter[i]) == 0)
{
found = i;
break;
}
}
if (found != -1)
break;
}
if (found == -1)
result = NULL;
else
{
if ((ptr) && (result->func))
{
ptr = result->func(result, ptr);
if (ptr == NULL)
result = NULL;
}
if (ptr)
{
#ifdef ENABLE_VERBOSE
printf("Setting %s = %s\n", result->summary, ptr);
#endif
switch (result->type)
{
case ST_BOOLEAN :
{
bool *variable = result->value;
*variable = isBoolean(ptr);
break;
}
case ST_INTEGER :
{
long *variable = result->value;
*variable = atoi(ptr);
break;
}
case ST_STRING :
{
char *variable = result->value;
strncpy(variable, ptr, result->max_size);
break;
}
}
}
}
free(dat);
}
return result;
}
void
save_setup (void)
{
struct setup_parameter *result = NULL;
printf("*** Writing setup file: %s (%s)\n", SETUP, date());
remove(TMP_FILE);
for (result = &parameters[0]; result->parameter[0] != NULL; result++)
{
switch (result->type)
{
case ST_BOOLEAN :
{
bool *variable = result->value;
db_log(TMP_FILE, "%s=%d\n", result->parameter[0], (*variable) ? 1 : 0);
break;
}
case ST_INTEGER :
{
long *variable = result->value;
db_log(TMP_FILE, "%s=%ld\n", result->parameter[0], *variable);
break;
}
case ST_STRING :
{
char *variable = result->value;
db_log(TMP_FILE, "%s=%s\n", result->parameter[0], variable);
break;
}
}
}
rename(TMP_FILE, SETUP);
}

File Metadata

Mime Type
application/octet-stream
Expires
Wed, Jul 16, 14:57 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2819107
Default Alt Text
(427 KB)

Event Timeline