1 /* 2 * Darkbot - Internet Relay Chat Help Robot, defines.h 3 * 4 * Copyright (C) 2000 Jason Hamilton <jason@darkbot.net> 5 * http://darkbot.net 6 * 7 * Join our mailing list! email darkbot-request@darkbot.net 8 * with a subject of "subscribe" 9 10 ,-----------------------------------------------------------------, 11 | Modify your darkbot settings by changing the values of the data | 12 | below. If you're not sure, leave the default settings alone :) | 13 `-----------------------------------------------------------------' */ 14 15 16 17 /* change the signal.h path below if it's not in the standard place */ 18 #include <signal.h> 19 20 /* Modify the following defines if needed ------------------------- */ 21 /* Please note that the below defines are the RECOMMENDED settings! */ 22 /* So if you don't know if you should change something, leave it :) */ 23 24 #define NEED_CLOCK_T OFF 25 /** 26 * If you have Mandrake, or are getting errors complaining 27 * about clock_t and CLOCKS_PER_SEC not being available, 28 * turn this option ON. This includes <time.h> in addition 29 * to <sys/time.h> and shuts it up. 30 */ 31 32 #define NEED_LIBC5 OFF 33 /** 34 * If you have an OS like Linux, you -may- need this defined. You'll 35 * know if your shell requires this define because your bot will connect 36 * but not say anything :) 37 * 38 * Most BSD systems will not need this, but some Linux systems may 39 * require it. <green@crimea.edu> 40 * 41 * ALSO NOTE: If your bot seems to disconnect every 5 minutes, try 42 * turning off the CHECK_STONED code. 43 */ 44 45 #define SGI OFF 46 /** 47 * SGI boxes (ie; IRIX system) need this 48 * define to run. Added by fouton 49 * <c592030@everest.cclabs.missouri.edu> 50 */ 51 52 #define LANG 1 53 /** 54 * What language do you want your darkbot to 55 * speak in? Pick a number from below. 56 * ------------------------------------------- 57 * 1 = ENGLISH - play <jason@darkbot.net> 58 * 2 = FRENCH - Inajira <inajira@videotron.ca> 59 * EfX <michel.efx@globetrotter.net> 60 * eCHaLoTTe <echalotte@cablevision.qc.ca> 61 * 3 = SPANISH - speed1 <speed@eduredes.edu.do> 62 * 4 = DUTCH - Asmodai <asmodai@wxs.nl> 63 * 5 = LATIN - Otaku <otaku@unixgeek.ml.org> 64 * 6 = GREEK - Chris_CY <chriscy@cylink.net> 65 * 7 = EBONICS - rapsux <bitter@ici.net> 66 * 8 = PIG LATIN- Cloud <burtner@usa.net> 67 * 9 = RUSSIAN - KOI8 encoding 68 * 10= RUSSIAN - CP1251 encoding 69 * - Oleg Drokin <green@ccssu.crimea.ua> 70 * 11= PORTUGUESE- Pincel <Pincel@darkbot.info> 71 * 12= GERMAN - C.Hoegl@gmx.net & marc@reymann.net 72 * 13= ITALIAN - daniele nicolucci <jollino@icemail.it> 73 * 14= CHINISE - James <jamespower@263.net> 74 * 15= SWEDISH - Ybznek <sunmo@seaside.se> 75 * 16= NORWEGIAN- [SoHo] <soho@int19h.com> 76 * 17= ROMANIAN - Radu <radu.negoescu@sante.univ-nantes.fr> 77 * ------------------------------------------------- 78 * ? = Email me if you want to help add other langs! 79 * ------------------------------------------------- 80 */ 81 82 #define DO_CHANBOT_CRAP ON 83 /** 84 * Enable this if you want to make your darkbot bloated 85 * with stuff like !KICK, !UP, !WACK, etc. Basically 86 * anything dealing with channel modes and kicking commands. 87 * This includes PERMBANS. On linux, without this, your 88 * darkbot bin will shrink from 82k to 78k in size. 89 */ 90 91 #define GENERAL_QUESTIONS ON 92 /** 93 * Answer questions that match a topic 94 * without addressing the bot (recommended) 95 */ 96 97 #define KICK_ON_CHANNEL_NOTICE OFF 98 /** 99 * Sometimes morons like to /notice flood channels. 100 * This define will make the bot kick those people 101 * when they do a channel notice. */ 102 #define BAN_ON_CHANNEL_NOTICE OFF 103 /** 104 * If you want to take it a step further, you can also 105 * have the bot ban the user@host too. */ 106 #define BAN_BY_HOST OFF 107 /** 108 * Finally, we can ban by *@host. This requires the 109 * above two to be turned on. 110 */ 111 112 #define STATUS OFF 113 /** 114 * Parse luser data? May cause SIG_SEGV on 115 * some ircd's (ie; non ircu) Basically all this does 116 * is display network info like opers, servers, avg # 117 * of users on the servers, etc. 118 */ 119 120 #define DISPLAY_SYNC OFF 121 /** 122 * When bot joins a channel, sometimes it's hard 123 * to tell when it's "synced" and is no longer processing 124 * stuff -- this tells the channel the bot has finished 125 * syncing. For example, if you try to login while it's 126 * still syncing, it may just ignore your login request 127 * until it sees you in the channel. 128 */ 129 130 #define BITCH_ABOUT_DEOP OFF 131 /** 132 * will complain in the chan that the bot is deoped in. 133 */ 134 135 #define DEFAULT_UMODE "+i-ds" 136 /** 137 * What user modes do you want for darkbot? 138 */ 139 140 #define HELP_GREET OFF 141 /** 142 * Give user's who join a NOTICE with info on how to use the darkbot? 143 * I don't bother with this anymore since my bot knows how to respond 144 * to most general questions users ask. If your bot is new and doesn't 145 * know much, then you may want to have it tell people how to use it. 146 */ 147 148 #define JOIN_GREET ON 149 /** 150 * Have the bot do auto-greets for users in the userlist? 151 */ 152 153 #define CTCP ON 154 /** 155 * Reply to CTCP's? (PING/VERSION). */ 156 157 #define VERSION_REPLY "Hi, I'm a Darkbot. Download me from http://darkbot.net" 158 /** 159 * This is the text the bot will reply when versioned. Change it 160 * to whatever you want. 161 */ 162 163 #define CHECK_STONED ON 164 /** 165 * Check if servers are not responding, is so 166 * connect to next server in list. (recommended) 167 * Some linux systems have problems with this. 168 * You'll know if you're one of them if your bot 169 * disconnects every 5 minutes. 170 */ 171 172 #define KICK_ON_BAN OFF 173 /** 174 * Kick people out when they are banned? 175 */ 176 177 #define DO_WHOIS OFF 178 /** 179 * Want to be alerted when a user who joins 180 * is in "questionable" other channels? This 181 * option only works on Undernet - since the 182 * NOTICE sent uses /notice @#chan 183 */ 184 185 #define LASTCOMM_TIME 5 186 /** 187 * LASTCOMM_TIME is the length of time (in seconds) 188 * that your bot will not reply to a topic already 189 * asked. Thus if someone asked your bot about "mirc" 190 * that question could not be asked again in the 191 * same format for N seconds (or till the question 192 * is out of buffer). This prevents the bot from 193 * falling prey to users who like to repeat. 194 */ 195 196 #define SLASTCOMM_TIME 60 197 /** 198 * This is the length of time to NOT allow someone 199 * to be recounted when they rejoin your channels, 200 * which tends to clutter up everyone's screen with 201 * the setinfo. This basically keeps track of who 202 * joined in the last ___ seconds, and does not do 203 * their setinfo during that amount of time. 204 */ 205 206 /** 207 * BELOW is the output timers. Darkbot does not 208 * output text without first putting it into a 209 * que list. If the bot has several lines of text 210 * waiting to be sent, it starts to delay longer 211 * and longer between output, so it can't flood 212 * itself off of IRC. Explanation: 213 * 214 * If text in que is < OUTPUT1_COUNT, output it. 215 * If text in que is > OUTPUT1_COUNT, delay 216 * OUTPUT1_DELAY seconds. If que is > OUTPUT2_COUNT, 217 * delay OUTPUT2_DELAY seconds. If number of text 218 * in que is higher than OUTPUT_PURGE_COUNT, then 219 * just delete all unneeded output (ie; any text 220 * and notices, but leaving in stuff like kicks 221 * and modes) The defaults below are recommended, 222 * as the bot isn't going to flood off. If you are 223 * having the bot delete output messages and you'd 224 * like to increase the que, update the 225 * OUTPUT_PURGE_COUNT to a larger number. Just keep 226 * in mind if someone floods your bot with a lot of 227 * VERSION requests, the bot will sit there outputting 228 * a lot of version replies instead of deleting them, 229 * causing it to act as if it's just sitting there not 230 * doing anything when you ask it something in your 231 * channel. 232 */ 233 #define OUTPUT1_COUNT 4 234 #define OUTPUT1_DELAY 1 235 #define OUTPUT2_COUNT 6 236 #define OUTPUT2_DELAY 2 237 /** 238 * If still < OUTPUT_PURGE_COUNT and > OUTPUT2_COUNT 239 * then delay OUTPUT3_DELAY secs 240 */ 241 #define OUTPUT3_DELAY 3 242 /** 243 * When all else fails... if more than OUTPUT_PURGE_COUNT 244 * delete them all! No use in making the bot output slowly 245 * over a long period of time... imagine if you set this to 246 * 50, and had an OUTPUT3_DELAY of 3 secs.. thats 50*3 secs 247 * till the bot is ready to output any new data to you! 248 */ 249 #define OUTPUT_PURGE_COUNT 7 250 251 #define ALLOW_RAW_TOPICS_USING_MODE OFF 252 /** 253 * Allow the raw topics to use MODE? This is not 254 * recommended because level 1 users can add topics 255 * such as "MODE C~ +o N~" and thus get ops, this is 256 * not a recommended define, but is here just in case 257 * some of you have special needs for the MODE. Please 258 * keep in mind you can do BANS without this define by 259 * using the raw topics -BAN and -TEMPBAN (ban for 60 secs). 260 */ 261 262 #define LOG_PRIVMSG ON 263 /** 264 * Do you want to log all privmsg's to your 265 * darkbot? (will be saved to logs/ dir) 266 */ 267 268 #define DISALLOW_COUNT 269 /** 270 * Your darkbot tell you (at startup) what the latest version of 271 * darkbot is. If you DO NOT WANT THIS, then define this. We recommend 272 * keeping this defined. 273 */ 274 275 /* 276 * The following should remain defined, however you can change them to 277 * whatever you want, to customize your darkbot - They are less important 278 * than the above defines, so generally speaking, there isn't a NEED to 279 * mess with them. 280 */ 281 282 #define COMPLAIN_REASON "grrr, kick me again and I'm going to..." 283 #define DONT_THINK_SO "I don't think so." 284 #define WHUT "hmmm?" 285 #define DONNO_Q "*shrug*" 286 #define FLOOD_REASON "Don't flood!" 287 #define DEFAULT_KICK "Requested!" 288 #define CANT_FIND "Was unable to find" /* ... */ 289 #define NO_TOPIC "Sorry, I don't have any entry for" /* ... */ 290 #define EXISTING_ENTRY "Sorry, there is an existing entry under keyword" 291 #define NO_ENTRY "I was unable to find entry:" 292 #define TRY_FIND "What am I trying to find" 293 #define WAKEUP_ACTION "\1ACTION wakes up from a snooze..\1" 294 #define GOSLEEP_ACTION "\1ACTION falls asleep... ZzzZZzzZZzz\1" 295 #if BITCH_ABOUT_DEOP == 1 296 #define BITCH_DEOP_REASON "grr, someone op me!" 297 #endif 298 299 #define SORT 300 /** 301 * Sort your info2.db on startup? Will take 302 * forever if u have a large db 303 */ 304 305 #undef LOG_ADD_DELETES 306 /** Do you want to log who adds/deletes 307 * topics? log saved to logs/add_delete.log 308 */ 309 310 #undef FIND_DUPS 311 /** 312 313 * When user's do the INFO command, and at 314 * startup, do you want to find and remove 315 * duplicates database entries? 316 */ 317 318 #undef SAVE_DUPS 319 /** When duplicate topics are found, do you 320 * want to save them? (in case some topics 321 * are accidently deleted) 322 */ 323 324 #define MAX_LASTSEEN 604800 325 /** 326 * Max length to keep a lastseen (default is 327 * one week (in seconds)) 328 */ 329 330 #define SEEN_REPLY "in the last week." 331 /** 332 * if you change the above 333 * time (MAX_LASTSEEN) from a 334 * week, be sure to update 335 * the SEEN_REPLY to the 336 * respective time length 337 */ 338 339 #define DO_MATH_STUFF 340 /** 341 * Do you want your bot to do math commands? 342 * This _MAY_ cause probs on some boxes, but 343 * so far worked fine on all I've seen. 344 */ 345 346 #define FLOOD_KICK 347 /** 348 * Define this if you want your darkbot to 349 * KICK out the people who flood it. NOTE: This 350 * means flooding your BOT, not your CHANNEL. If you 351 * don't define this, it will just ignore the user 352 */ 353 354 #define REQ_ACCESS_ADD 355 /** 356 * Require access to add help topics? 357 */ 358 359 #define REQ_ACCESS_DEL 360 /** 361 * Require access to delete help topics? 362 */ 363 364 #define RAND_STUFF_TIME 3600 365 /** 366 * Time in seconds to randomly do something 367 * from dat/random.ini (default is 1 hour) 368 */ 369 370 #define RAND_LEVEL 2 371 /** 372 * Level at which user's can on-line add new 373 * randomstuff topics, this also is the level at which 374 * users will be able to add RDB topics 375 */ 376 377 #define RANDOM_STUFF 378 /** 379 * Will read from a random line in 380 * dat/randomstuff.ini and say something 381 * random in the home channel. ALSO if 382 * nothing is said in darkbot's home channel 383 * it will say a randomstuff every RAND_IDLE 384 * as long as no one says anything.. 385 */ 386 387 #define RAND_IDLE 1800 388 /** 389 * Time in secs to say something in home chan 390 * when no one says anything (this overrides 391 * the RAND_STUFF_TIME counter (default is 10 392 * min) 393 */ 394 395 #undef ANTI_IDLE 396 /** 397 * Want your darkbot to always have less than 398 * 10 min idle? This isn't usually needed since 399 * darkbots tend to talk a lot. 400 */ 401 402 #define SLEEP_LEVEL 3 403 /** 404 * Level at which user's can make darkbot 405 * shut up (aka hush) This is useful for help 406 * channels when they want darkbot to quit 407 * talking while they address something 408 * important in the chan 409 */ 410 411 #define SLEEP_TIME 400 412 /** 413 * How many seconds to sleep for? 414 */ 415 416 #define AUTOTOPIC_TIME 1800 417 /** 418 * Autotopic time in seconds - default 419 * is 30 min 420 */ 421 422 #define MAX_DATA_SIZE 400 423 /** 424 * The max size your database topics will be 425 * This will be useful to people loading 426 * their database into ram - if your data is 427 * all less than 400 chars, then you can save 428 * some ram.... Longer allows you to do more 429 * with PIPE topics (see README for 4f3) 430 */ 431 432 #define MAX_TOPIC_SIZE 50 433 /** 434 * Max topic length 435 */ 436 437 #define VERB 438 /** 439 * Print out extra details while starting up? 440 */ 441 442 /* Below are variables for the data replys */ 443 #define myVariables "data variables are: N~ (Nick), C~ (Chan), T~ \ 444 (Time/date) B~ (Botnick), Q~ (Question asked), R~ (random nick), !~ \ 445 (command char), S~ (current Server), P~ (current port) V~ (botVer), W~ \ 446 (db WWW site), H~ (u@h), t~ (unixtime), BAN (sets a ban), TEMPBAN (bans \ 447 for 60 sec)" 448 449 #define mySetinfo "My !setinfo variables are: ^ nick, % Number of joins, & \ 450 Channel, $ user@host. Example: !setinfo ^ has joined & % times!! (also, if \ 451 you make the first char of your SETINFO a \"+\" the setinfo will be shown \ 452 as an ACTION)" 453 454 #define L100(s,a,b,c,d,e,f) S("NOTICE %s :I can be triggered by various \ 455 forms of speech, all which must be addressed to me, in one of the \ 456 following formats: %s %s %s or even %s .... In my database, you can \ 457 find a topic by saying my nick, <topic> . eg; \37%s nuke\37 ..... \ 458 to do a search on a word, or partial text, just type: <mynick>, search \ 459 <text> ... eg; \37%s search nuke\37\n",s,a,b,c,d,e,f) 460 461 #define L101(a,b,c,d) S("NOTICE %s :I can also be triggered with even more \ 462 human formats: \37%s who is bill gates?\37 .. You can also phrase it \ 463 in a question: \37%s where is msie?\37 ...For more info \ 464 about me, visit http://darkbot.net\n",a,b,c,d) 465 466 #define L102(a,b,c,d) S("NOTICE %s :Welcome to %s, %s. Before \ 467 asking your question, type %cHELP for a list of help topics.\n", a,b,c,d) 468 469 470 471 /* ################################################## */ 472 /* ---- Don't change anything else below! ----------- */ 473 /* ################################################## */ 474 #define fr 3 /* these two are the # of lines per secs */ 475 #define ft 3 476 #define AIL 1 477 #define WSEC 10 478 #define USEC 0 479 #define RECHECK 45 480 #define DBTIMERS_PATH "timers" 481 #define LOG_DIR "/usr/local/etc/darkbot/logs/" 482 #define SEEN_FILE "/usr/local/etc/darkbot/dat/seen.db" 483 #define URL2 "/usr/local/etc/darkbot/dat/info2.db" 484 #define BACKUP_DUP "/usr/local/etc/darkbot/dat/backup_dups.db" 485 #define ADD_DELETES "/usr/local/etc/darkbot/logs/add_delete.log" 486 #define TMP_URL "/usr/local/etc/darkbot/.info.tmp" 487 #define TMP_FILE "/usr/local/etc/darkbot/.file.tmp" 488 #define AUTOTOPIC_F "/usr/local/etc/darkbot/dat/autotopic.ini" 489 #define HELPER_LIST "/usr/local/etc/darkbot/dat/userlist.db" 490 #define PERFORM "/usr/local/etc/darkbot/dat/perform.ini" 491 #define DEOP "/usr/local/etc/darkbot/dat/deop.ini" 492 #define RAND_SAY "/usr/local/etc/darkbot/dat/random.ini" 493 #define RAND_FILE "/usr/local/etc/darkbot/dat/randomstuff.ini" 494 #define SERVERS "/usr/local/etc/darkbot/dat/servers.ini" 495 #define PERMBAN "/usr/local/etc/darkbot/dat/permbans.db" 496 #define SETUP "/usr/local/etc/darkbot/dat/setup.ini" 497 #define MAX_SEARCH_LENGTH 350 498 /* -------------------------------------------------- */ 499 500 #include "langs/lang.h" 501 #include <ctype.h> 502 #include <stdio.h> 503 #if NEED_CLOCK_T == ON 504 #include <time.h> 505 #endif 506 #include <sys/time.h> 507 #include <sys/types.h> 508 #include <sys/socket.h> 509 #include <sys/resource.h> 510 #include <string.h> 511 #include <unistd.h> 512 #include <stdarg.h> 513 #include <errno.h> 514 #include <stdlib.h> 515 #include <netdb.h> 516 #include <netinet/in.h> 517 #include <arpa/inet.h> 518 #include <assert.h> 519 #ifdef WIN32 520 #include <windows.h> 521 #endif 522 #include <signal.h> 523 #include <dirent.h> 524 #include <sys/stat.h> 525 526 #define db_sleep(x) usleep(x*1000) 527 528 #ifndef __cplusplus 529 typedef enum 530 { false, true } 531 bool; 532 #endif 533 534 #ifdef WIN32 535 typedef unsigned int size_t; 536 #endif 537