10
10
* 1.2 1997-08-20 Minor fixes. [BB]
11
11
* 1.2a 1997-08-24 Minor fixes. [BB]
13
* $Id: seen.c,v 1.24 2002/01/02 03:46:39 guppy Exp $
13
* $Id: seen.c,v 1.33 2004/01/09 05:56:38 wcc Exp $
16
* Copyright (C) 1999, 2000, 2001, 2002 Eggheads Development Team
16
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Eggheads Development Team
18
18
* This program is free software; you can redistribute it and/or
19
19
* modify it under the terms of the GNU General Public License
95
static trig_data trigdata[] =
97
{"god", "Let's not get into a religious discussion, %s"},
98
{"jesus", "Let's not get into a religious discussion, %s"},
99
{"shit", "Here's looking at you, %s"},
100
{"yourself", "Yeah, whenever I look in a mirror..."},
101
{NULL, "You found me, %s!"},
102
{"elvis", "Last time I was on the moon man."},
108
static trig_data trigdata[] = {
109
{"god", "Let's not get into a religious discussion, %s"},
110
{"jesus", "Let's not get into a religious discussion, %s"},
111
{"shit", "Here's looking at you, %s"},
112
{"yourself", "Yeah, whenever I look in a mirror..."},
113
{NULL, " You found me, %s!"},
114
{"elvis", "Last time I was on the moon man."},
106
118
static int seen_expmem()
113
123
/* PUB `seen' trigger. */
114
124
static int pub_seen(char *nick, char *host, char *hand,
115
char *channel, char *text)
125
char *channel, char *text)
127
char prefix[91]; /* sizeof(name) + strlen("PRIVMSG :") */
118
128
struct chanset_t *chan = findchan_by_dname(channel);
120
130
if ((chan != NULL) && channel_seen(chan)) {
121
sprintf(prefix, "PRIVMSG %s :", chan->name);
131
egg_snprintf(prefix, sizeof prefix, "PRIVMSG %s :", chan->name);
122
132
do_seen(DP_HELP, prefix, nick, hand, chan->dname, text);
171
181
/* Was ANYONE specified */
173
183
dprintf(idx, "%sUm, %s, it might help if you ask me about _someone_...\n",
177
187
wordshift(word1, text);
178
188
oix = strchr(word1, '\'');
179
189
/* Have we got a NICK's target? */
180
190
if (oix == word1)
181
return; /* Skip anything starting with ' */
183
((oix[1] && (oix[1] == 's' || oix[1] == 'S') && !oix[2]) ||
185
(oix[-1] == 's' || oix[-1] == 'z' || oix[-1] == 'x' ||
186
oix[-1] == 'S' || oix[-1] == 'Z' || oix[-1] == 'X')))) {
191
return; /* Skip anything starting with ' */
192
if (oix && *oix && ((oix[1] && (oix[1] == 's' || oix[1] == 'S') &&
193
!oix[2]) || (!oix[1] && (oix[-1] == 's' || oix[-1] == 'z' ||
194
oix[-1] == 'x' || oix[-1] == 'S' || oix[-1] == 'Z' ||
187
196
strncpy(object, word1, oix - word1);
188
197
object[oix - word1] = 0;
189
198
wordshift(word1, text);
199
m = ismember(chan, object);
202
sprintf(stuff, "%s!%s", object, m->userhost);
203
urec = get_user_by_host(stuff);
204
if (!urec || !egg_strcasecmp(object, urec->handle))
206
strcat(whoredirect, object);
207
strcat(whoredirect, " is ");
208
strcat(whoredirect, urec->handle);
209
strcat(whoredirect, ", and ");
210
strcpy(object, urec->handle);
208
m = ismember(chan, object);
211
sprintf(stuff, "%s!%s", object, m->userhost);
212
urec = get_user_by_host(stuff);
213
if (!urec || !egg_strcasecmp(object, urec->handle))
215
strcat(whoredirect, object);
216
strcat(whoredirect, " is ");
217
strcat(whoredirect, urec->handle);
218
strcat(whoredirect, ", and ");
219
strcpy(object, urec->handle);
216
dprintf(idx, "%sI don't think I know who %s is, %s.\n",
217
prefix, object, nick);
225
dprintf(idx, "%sI don't think I know who %s is, %s.\n",
226
prefix, object, nick);
221
230
if (!egg_strcasecmp(word1, "bf") || !egg_strcasecmp(word1, "boyfriend")) {
222
231
strcpy(whotarget, getxtra(object, "BF"));
223
232
if (whotarget[0]) {
224
sprintf(whoredirect, "%s boyfriend is %s, and ",
225
fixnick(object), whotarget);
233
sprintf(whoredirect, "%s boyfriend is %s, and ",
234
fixnick(object), whotarget);
229
"%sI don't know who %s boyfriend is, %s.\n",
230
prefix, fixnick(object), nick);
238
"%sI don't know who %s boyfriend is, %s.\n",
239
prefix, fixnick(object), nick);
233
242
if (!egg_strcasecmp(word1, "gf") || !egg_strcasecmp(word1, "girlfriend")) {
234
243
strcpy(whotarget, getxtra(object, "GF"));
235
244
if (whotarget[0]) {
236
sprintf(whoredirect, "%s girlfriend is %s, and ",
237
fixnick(object), whotarget);
245
sprintf(whoredirect, "%s girlfriend is %s, and ",
246
fixnick(object), whotarget);
241
"%sI don't know who %s girlfriend is, %s.\n",
242
prefix, fixnick(object), nick);
250
"%sI don't know who %s girlfriend is, %s.\n",
251
prefix, fixnick(object), nick);
246
"%sWhy are you bothering me with questions about %s %s, %s?\n",
247
prefix, fixnick(object), word1, nick);
255
"%sWhy are you bothering me with questions about %s %s, %s?\n",
256
prefix, fixnick(object), word1, nick);
250
259
/* Keyword "my" */
257
266
/* Do I even KNOW the requestor? */
258
267
if (hand[0] == '*' || !hand[0]) {
260
"%sI don't know you, %s, so I don't know about your %s.\n",
261
prefix, nick, word1);
269
"%sI don't know you, %s, so I don't know about your %s.\n",
270
prefix, nick, word1);
264
273
/* "my boyfriend" */
265
274
if (!egg_strcasecmp(word1, "boyfriend") || !egg_strcasecmp(word1, "bf")) {
266
275
strcpy(whotarget, getxtra(hand, "BF"));
267
276
if (whotarget[0]) {
268
sprintf(whoredirect, "%s, your boyfriend is %s, and ",
277
sprintf(whoredirect, "%s, your boyfriend is %s, and ", nick, whotarget);
272
"%sI didn't know you had a boyfriend, %s\n",
279
dprintf(idx, "%sI didn't know you had a boyfriend, %s\n", prefix, nick);
277
283
/* "my girlfriend" */
278
284
else if (!egg_strcasecmp(word1, "girlfriend") ||
279
!egg_strcasecmp(word1, "gf")) {
285
!egg_strcasecmp(word1, "gf")) {
280
286
strcpy(whotarget, getxtra(hand, "GF"));
281
287
if (whotarget[0]) {
282
sprintf(whoredirect, "%s, your girlfriend is %s, and ",
288
sprintf(whoredirect, "%s, your girlfriend is %s, and ",
286
"%sI didn't know you had a girlfriend, %s\n",
291
dprintf(idx, "%sI didn't know you had a girlfriend, %s\n", prefix,
292
"%sI don't know anything about your %s, %s.\n",
293
prefix, word1, nick);
296
dprintf(idx, "%sI don't know anything about your %s, %s.\n", prefix,
300
304
/* "your admin" */
301
305
if (!egg_strcasecmp(word1, "owner") || !egg_strcasecmp(word1, "admin")) {
303
strcpy(word2, admin);
304
wordshift(whotarget, word2);
305
strcat(whoredirect, "My owner is ");
306
strcat(whoredirect, whotarget);
307
strcat(whoredirect, ", and ");
308
if (!egg_strcasecmp(whotarget, hand)) {
309
strcat(whoredirect, "that's YOU");
310
if (!egg_strcasecmp(hand, nick)) {
311
strcat(whoredirect, "!!!");
313
strcat(whoredirect, ", ");
314
strcat(whoredirect, nick);
315
strcat(whoredirect, "!");
317
dprintf(idx, "%s%s\n", prefix, whoredirect);
320
} else { /* owner variable munged or not set */
322
"%sI don't seem to recall who my owner is right now...\n",
307
strcpy(word2, admin);
308
wordshift(whotarget, word2);
309
strcat(whoredirect, "My owner is ");
310
strcat(whoredirect, whotarget);
311
strcat(whoredirect, ", and ");
312
if (!egg_strcasecmp(whotarget, hand)) {
313
strcat(whoredirect, "that's YOU");
314
if (!egg_strcasecmp(hand, nick))
315
strcat(whoredirect, "!!!");
317
strcat(whoredirect, ", ");
318
strcat(whoredirect, nick);
319
strcat(whoredirect, "!");
321
dprintf(idx, "%s%s\n", prefix, whoredirect);
324
} else { /* owner variable munged or not set */
326
"%sI don't seem to recall who my owner is right now...\n",
326
} else { /* no "your" target specified */
327
dprintf(idx, "%sLet's not get personal, %s.\n",
330
} else { /* no "your" target specified */
331
dprintf(idx, "%sLet's not get personal, %s.\n", prefix, nick);
371
374
m = chan->channel.member;
372
375
while (m && m->nick[0]) {
373
sprintf(word2, "%s!%s", m->nick, m->userhost);
374
urec = get_user_by_host(word2);
375
if (urec && !egg_strcasecmp(urec->handle, whotarget)) {
377
strcat(whoredirect, whotarget);
378
strcat(whoredirect, " is ");
379
strcat(whoredirect, m->nick);
380
strcat(whoredirect, ", and ");
381
strcpy(whotarget, m->nick);
376
sprintf(word2, "%s!%s", m->nick, m->userhost);
377
urec = get_user_by_host(word2);
378
if (urec && !egg_strcasecmp(urec->handle, whotarget)) {
380
strcat(whoredirect, whotarget);
381
strcat(whoredirect, " is ");
382
strcat(whoredirect, m->nick);
383
strcat(whoredirect, ", and ");
384
strcpy(whotarget, m->nick);
386
389
chan = chan->next;
392
395
m = ismember(chan, whotarget);
393
396
if (m && chan_issplit(m)) {
394
397
dprintf(idx, "%s%s%s was just here, but got netsplit.\n",
395
prefix, whoredirect, whotarget);
398
prefix, whoredirect, whotarget);
399
402
/* Check if the target IS on the channel */
401
404
dprintf(idx, "%s%s%s is on the channel right now!\n",
402
prefix, whoredirect, whotarget);
405
prefix, whoredirect, whotarget);
405
408
/* Target not on this channel. Check other channels */
408
411
m = ismember(chan, whotarget);
409
412
if (m && chan_issplit(m)) {
411
"%s%s%s was just on %s, but got netsplit.\n",
412
prefix, whoredirect, whotarget, chan->dname);
414
"%s%s%s was just on %s, but got netsplit.\n",
415
prefix, whoredirect, whotarget, chan->dname);
417
"%s%s%s is on %s right now!\n",
418
prefix, whoredirect, whotarget, chan->dname);
420
"%s%s%s is on %s right now!\n",
421
prefix, whoredirect, whotarget, chan->dname);
421
424
chan = chan->next;
434
437
for (i = 0; i < dcc_total; i++) {
435
438
if (dcc[i].type->flags & DCT_CHAT) {
436
439
if (!egg_strcasecmp(whotarget, dcc[i].nick)) {
437
if (!rfc_casecmp(channel, dcc[i].u.chat->con_chan) &&
438
dcc[i].u.chat->con_flags & LOG_PUBLIC) {
439
strcat(whoredirect, whotarget);
441
" is 'observing' this channel right now from my party line!");
442
dprintf(idx, "%s%s\n", prefix, whoredirect);
445
"%s%s%s is linked to me via DCC CHAT right now!\n",
446
prefix, whoredirect, whotarget);
440
if (!rfc_casecmp(channel, dcc[i].u.chat->con_chan) &&
441
dcc[i].u.chat->con_flags & LOG_PUBLIC) {
442
strcat(whoredirect, whotarget);
444
" is 'observing' this channel right now from my party line!");
445
dprintf(idx, "%s%s\n", prefix, whoredirect);
448
"%s%s%s is linked to me via DCC CHAT right now!\n",
449
prefix, whoredirect, whotarget);
478
481
work = now - laston;
479
482
if (work >= 86400) {
480
483
sprintf(word2, "%lu day%s, ", work / 86400,
481
((work / 86400) == 1) ? "" : "s");
484
((work / 86400) == 1) ? "" : "s");
482
485
work = work % 86400;
484
487
if (work >= 3600) {
485
488
sprintf(word2 + strlen(word2), "%lu hour%s, ", work / 3600,
486
((work / 3600) == 1) ? "" : "s");
489
((work / 3600) == 1) ? "" : "s");
487
490
work = work % 3600;
489
492
if (work >= 60) {
490
493
sprintf(word2 + strlen(word2), "%lu minute%s, ", work / 60,
491
((work / 60) == 1) ? "" : "s");
494
((work / 60) == 1) ? "" : "s");
493
496
if (!word2[0] && (work < 60)) {
494
497
strcpy(word2, "just moments ago!!");
551
554
ue = find_user_entry(&USERENTRY_XTRA, urec);
553
556
for (xk = ue->u.extra; xk; xk = xk->next)
554
if (xk->key && !egg_strcasecmp(xk->key, field)) {
555
if (xk->data[0] == '{' && xk->data[strlen(xk->data) - 1] == '}' &&
556
strlen(xk->data) > 2) {
557
strncpy(fixit, &xk->data[1], strlen(xk->data) - 2);
558
fixit[strlen(xk->data) - 2] = 0;
557
if (xk->key && !egg_strcasecmp(xk->key, field)) {
558
if (xk->data[0] == '{' && xk->data[strlen(xk->data) - 1] == '}' &&
559
strlen(xk->data) > 2) {
560
strncpy(fixit, &xk->data[1], strlen(xk->data) - 2);
561
fixit[strlen(xk->data) - 2] = 0;
579
582
/* Report on current seen info for .modulestat. */
580
583
static void seen_report(int idx, int details)
583
dprintf(idx, " seen.so - PUB, DCC and MSG \"seen\" commands.\n");
586
int size = seen_expmem();
588
dprintf(idx, " Using %d byte%s of memory\n", size,
589
(size != 1) ? "s" : "");
586
593
/* PUB channel builtin commands. */
587
static cmd_t seen_pub[] =
589
{"seen", "", pub_seen, NULL},
590
{NULL, NULL, NULL, NULL}
593
static cmd_t seen_dcc[] =
595
{"seen", "", dcc_seen, NULL},
596
{NULL, NULL, NULL, NULL}
599
static cmd_t seen_msg[] =
601
{"seen", "", msg_seen, NULL},
602
{NULL, NULL, NULL, NULL}
594
static cmd_t seen_pub[] = {
595
{"seen", "", pub_seen, NULL},
596
{NULL, NULL, NULL, NULL}
599
static cmd_t seen_dcc[] = {
600
{"seen", "", dcc_seen, NULL},
601
{NULL, NULL, NULL, NULL}
604
static cmd_t seen_msg[] = {
605
{"seen", "", msg_seen, NULL},
606
{NULL, NULL, NULL, NULL}
605
609
static int server_seen_setup(char *mod)
623
static cmd_t seen_load[] =
625
{"server", "", server_seen_setup, NULL},
626
{"irc", "", irc_seen_setup, NULL},
627
{NULL, NULL, NULL, NULL}
627
static cmd_t seen_load[] = {
628
{"server", "", server_seen_setup, NULL},
629
{"irc", "", irc_seen_setup, NULL},
630
{NULL, NULL, NULL, NULL}
630
633
static char *seen_close()
645
648
EXPORT_SCOPE char *seen_start();
647
static Function seen_table[] =
650
static Function seen_table[] = {
649
651
(Function) seen_start,
650
652
(Function) seen_close,
651
653
(Function) seen_expmem,
652
654
(Function) seen_report,
655
char *seen_start(Function * egg_func_table)
657
char *seen_start(Function *egg_func_table)
657
659
global = egg_func_table;
659
661
module_register(MODULE_NAME, seen_table, 2, 0);
660
662
if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
661
663
module_undepend(MODULE_NAME);
662
return "This module needs eggdrop1.6.0 or later";
664
return "This module requires Eggdrop 1.6.0 or later.";
664
666
add_builtins(H_load, seen_load);
665
667
add_builtins(H_dcc, seen_dcc);