download Adbseen192.tcl
Language: Tcl
LOC: 406
Project Info
xbot4 - The version of X-Bot to supercede ... 2003(xbot4)
Server: Google
Type: svn
...\bin\Debug\xTclLib\scripts\
   _BotnetStats1.9.desc
   _cutetopics100.desc
   _dict109.desc
   _entity92.desc
   _hangman101.desc
   _infobottcl.desc
   _jesusbot1.0.desc
   _jIRCserv-0.02n.desc
   _Lusers.desc
   _mp3list100.desc
   _MsgLog1.1.desc
   _mysqlseen1.1.desc
   _newtopics.desc
   _no.spam.desc
   _quizgod.desc
   _serials100.desc
   _skool101.desc
   _Split4.1.desc
   _thehelper100.desc
   _topicmaster1.1.desc
   _trivia.desc
   _UltramodeNews10.desc
   _UndernetCS.desc
   _userquotes100.desc
   _Veed_0.2.desc
   _WebBanList1.1.desc
   _words100.desc
   _zipcodes100.desc
   abuse100.desc
   abuse100.tcl
   action.fix.desc
   action.fix.tcl
   activech100.desc
   activech100.tcl
   adbseen192.desc
   Adbseen192.tcl
   addban10-mbti.desc
   addban10-mbti.tcl
   added140.desc
   Added140.tcl
   addicted100.desc
   addicted100.tcl
   advert105.desc
   advert105.tcl
   alice120.desc
   alice120.tcl
   alltools.desc
   alltools.tcl
   antiidle-narf-0.3.desc
   antiidle-narf-0.3.tcl
   auth103.desc
   auth103.tcl
   autolimit102.desc
   autolimit102.tcl
   autooper.desc
   autooper.tcl
   av.pubmsg.desc
   av.pubmsg.tcl
   bancheck.desc
   bancheck.tcl
   BanCount1.1.desc
   BanCount1.1.tcl
   BanTools1.2.desc
   BanTools1.2.tcl
   bitchxirix.desc
   bitchxirix.tcl
   bot-solutions.3.0.desc
   bot-solutions.3.0.tcl
   botping.desc
   botping.tcl
   bwscript20.desc
   bwscript20.tcl
   chancheck100.desc
   chancheck100.tcl
   ChanMax1.2.desc
   ChanMax1.2.tcl
   ChanPeak1.3.desc
   ChanPeak1.3.tcl
   chanrelay.desc
   chanrelay.tcl
   ClanAvail1.4.desc
   ClanAvail1.4.tcl
   ClanBase1.1.desc
   ClanBase1.1.tcl
   cmd_resolve.desc
   cmd_resolve.tcl
   compat.desc
   compat.tcl
   CopyVoice1.3.desc
   CopyVoice1.3.tcl
   cracks100.desc
   cracks100.tcl
   DALnetNews1.1.desc
   DALnetNews1.1.tcl
   date1.3.desc
   date1.3.tcl
   DateToDay1.0.desc
   DateToDay1.0.tcl
   daystill102.desc
   daystill102.tcl
   dccwatch104.desc
   dccwatch104.tcl
   Decide1.2.desc
   Decide1.2.tcl
   decide100.desc
   decide100.tcl
   define.desc
   define.tcl
   delhost1.01.desc
   delhost1.01.tcl
   delivery101.desc
   delivery101.tcl
   Dictionary1.1.desc
   Dictionary1.1.tcl
   DieAuth2.1.desc
   DieAuth2.1.tcl
   Dns2.5.desc
   Dns2.5.tcl
   DomainWhois1.2.desc
   DomainWhois1.2.tcl
   EFnetNews1.1.desc
   EFnetNews1.1.tcl
   egg-fu.1.7.desc
   egg-fu.1.7.tcl
   eggpad.desc
   eggpad.tcl
   englishonly102.desc
   englishonly102.tcl
   filerelay0.4.desc
   filerelay0.4.tcl
   fluxlearn1.5a.desc
   fluxlearn1.5a.tcl
   flyby101.desc
   flyby101.tcl
   gamble100.desc
   gamble100.tcl
   gamestar1.4.desc
   gamestar1.4.tcl
   GBan1.4.desc
   GBan1.4.tcl
   getops-2.6.desc
   getops-2.6.tcl
   getops.desc
   getops.tcl
   greeter101.desc
   greeter101.tcl
   guard101.desc
   guard101.tcl
   heise1.4.desc
   heise1.4.tcl
   HostSpy1.8.desc
   HostSpy1.8.tcl
   HostTools1.5.desc
   HostTools1.5.tcl
   HTMLOpVote2.0.desc
   HTMLOpVote2.0.tcl
   ident.desc
   ident.tcl
   ieXbeta1.1.desc
   ieXbeta1.1.tcl
   ilc100.desc
   ilc100.tcl
   infoegg-v1-3.desc
   infoegg-v1-3.tcl
   insult101.desc
   insult101.tcl
   inv.desc
   inv.tcl
   irco-fuckem.desc
   irco-fuckem.tcl
   irco-muh.desc
   irco-muh.tcl
   irco-psybnc.desc
   irco-psybnc.tcl
   irco-scanport.desc
   irco-scanport.tcl
   irco-soundkick.desc
   irco-soundkick.tcl
   irco-wingateban.desc
   irco-wingateban.tcl
   kick100.desc
   kick100.tcl
   kickad100.desc
   kickad100.tcl
   KillLog2.5.desc
   KillLog2.5.tcl
   klined.desc
   klined.tcl
   lamer.desc
   lamer.tcl
   lanparty.desc
   lanparty.tcl
   limit-v1.1.desc
   limit-v1.1.tcl
   limitchan.desc
   limitchan.tcl
   LinkedBots1.2.desc
   LinkedBots1.2.tcl
   maxvisitors101.desc
   maxvisitors101.tcl
   mc.banchan.desc
   mc.banchan.tcl
   mc.spamcheck.desc
   mc.spamcheck.tcl
   megadeth100.desc
   megadeth100.tcl
   mIRCShitlist1.2.desc
   mIRCShitlist1.2.tcl
   moi.desc
   moi.tcl
   netlink107.desc
   netlink107.tcl
   NetStats1.2.desc
   NetStats1.2.tcl
   news.desc
   news.tcl
   news2html.desc
   news2html.tcl
   NoAccess1.1.desc
   NoAccess1.1.tcl
   noads108.desc
   noads108.tcl
   noawayactions1.03.desc
   noawayactions1.03.tcl
   NoColors1.2.desc
   NoColors1.2.tcl
   nocomics100.desc
   nocomics100.tcl
   NoFservs1.5.desc
   NoFservs1.5.tcl
   nosense2.desc
   nosense2.tcl
   notes2.desc
   notes2.tcl
   NoTriggers2.3.desc
   NoTriggers2.3.tcl
   oannouce100.desc
   oannouce100.tcl
   ok1.3.desc
   ok1.3.tcl
   opbegger103.desc
   opbegger103.tcl
   opkillsnn.desc
   opkillsnn.tcl
   OpNotice1.9.desc
   OpNotice1.9.tcl
   pa-trgt3_68.desc
   pa-trgt3_68.tcl
   passgen.desc
   passgen.tcl
   pcgames.desc
   pcgames.tcl
   pickakick102.desc
   pickakick102.tcl
   PortCheck2.2.desc
   PortCheck2.2.tcl
   postal101.desc
   postal101.tcl
   Pub.desc
   Pub.tcl
   pwf.desc
   pwf.tcl
   ques5.desc
   ques5.tcl
   ran.desc
   ran.tcl
   RandRead1.1.desc
   RandRead1.1.tcl
   randtopic2.04.desc
   randtopic2.04.tcl
   recruiters100.desc
   recruiters100.tcl
   released102.desc
   released102.tcl
   SearchPage.desc
   SearchPage.tcl
   sentinel.desc
   sentinel.tcl
   Services2.0.desc
   Services2.0.tcl
   sharereactor1.0.desc
   sharereactor1.0.tcl
   ShellTime1.6.desc
   ShellTime1.6.tcl
   ShellUptime1.0.desc
   ShellUptime1.0.tcl
   shortnews.desc
   shortnews.tcl
   showchans104.desc
   showchans104.tcl
   sound_dos-0.02a.desc
   sound_dos-0.02a.tcl
   Spod.desc
   Spod.tcl
   spymsg.desc
   spymsg.tcl
   StockQuote.desc
   StockQuote.tcl
   striptease104.desc
   striptease104.tcl
   SubChan2.0.desc
   SubChan2.0.tcl
   superbitch0.45.desc
   superbitch0.45.tcl
   sync1.2.desc
   sync1.2.tcl
   tan101.desc
   tan101.tcl
   tempc100.desc
   tempc100.tcl
   textsearch0.2.desc
   textsearch0.2.tcl
   TimeIdent1.0.desc
   TimeIdent1.0.tcl
   TimeMessage1.0.desc
   TimeMessage1.0.tcl
   TimeRehash1.0.desc
   TimeRehash1.0.tcl
   tool-lyrics.desc
   tool-lyrics.tcl
   top10.desc
   top10.tcl
   topiclock2.04.desc
   topiclock2.04.tcl
   topiclogger1.01.desc
   topiclogger1.01.tcl
   ucsx0.2.desc
   ucsx0.2.tcl
   uptime1.08.desc
   uptime1.08.tcl
   UrlGet1.4.desc
   UrlGet1.4.tcl
   userinfo.desc
   userinfo.tcl
   VerboseMail1.1.desc
   VerboseMail1.1.tcl
   Voice1.1.desc
   Voice1.1.tcl
   voiceallbut102.desc
   voiceallbut102.tcl
   voicebitch0.1.desc
   voicebitch0.1.tcl
   VoiceFservs1.3.desc
   VoiceFservs1.3.tcl
   vote1.14.desc
   vote1.14.tcl
   warn100.desc
   warn100.tcl
   weather3.3.1.desc
   weather3.3.1.tcl
   WebSiteStatus1.0.desc
   WebSiteStatus1.0.tcl
   Whatis1.5.desc
   Whatis1.5.tcl
   Whom1.0.desc
   Whom1.0.tcl
   winfuture.desc
   winfuture.tcl
   winident1.2.desc
   winident1.2.tcl
   worldtime.desc
   worldtime.tcl
   x-commands0.1.desc
   x-commands0.1.tcl
   zdnet1.1.desc
   zdnet1.1.tcl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
 #####
# !!!!!!! NOT A OFFICIAL RELEASE !!!!!!!!
# Multichannel seen implementation by PreSSo (andrejp@luz.fe.uni-lj.si)
# loosely based on seen by Robey
# will show when nicks were last seen on the channel(s) no matter
# if they are on the bot's userlist or not.
# requires eggdrop 1.3.x bot
# needs adbtools.tcl loaded!
# Repaired by Ze_PilOt for 1.3.x
#
# HISTORY:
# version 1.0 (dunno exactly, been a while)
# version 1.1 (6 Aug, 1996)
# - various small fixes
# version 1.2 (18 Aug, 1996)
# - new faster check_expired (this one really blows the socks off:)
# - changed default nickexpire to 30 days
# - various small changes
# version 1.3 (18 Aug, 1996)
# - added configurable bind msg/pub flags for users (see settings)
# version 1.4 (1 Sep, 1996)
# - added force update command. this was needed to fix the
# bug where bot was showing incorrect seen info for users
# that were added to the bot's userlist after they were
# already in the seen nicks list (.seenupd)
# - added dcc seen command
# version 1.5 (2 Oct, 1996)
# - the script now also reports how the user left (leave, kick..)
# - old seen.nicks file is no longer valid (delete it)
# - shows the channel where nick was last on for all nicks, not
# just valid users (the code was already there, just not used:)
# version 1.6 (17 Jan, 1997)
# - the bot now reports 'one of my channels' instead of '#channel'
# if the channel is marked +secret
# version 1.7 (24 Jan, 1997)
# - cosmetical fixes
# version 1.8 (25 Jan, 1997)
# - err...:) a little bug fix:) It won't putlog stupid things now:)
# version 1.9 (29 Jul, 1997)
# - changed and tuned script, so it should run on 1.1.5 now
#   Times for checking for expires (60 M.) and nicksaving (15 M.) are
#   now hardcoded, hey... who cares? I for my part don#t know why it
#   wouldn#t work with variables... Blackb|rd
# version 1.9.1 (10 Aug, 1997)
# - "corrected" and "rewrote" some of the answers (the grammar part
#   wasn't very good - my opinion... :)) - Queux
# version 1.9.2 (16 Dec, 1997) (non official release !!!)
# - I upgraded the script to use with eggdrop 1.3.x .. The seen on the
#   party don't work at 100%, but work perfectly on a channel ...
#
# COMMANDS:
# dcc, msg: seen <nick>
# public: !seen <nick>
#
# TODO:
# - nicks get added to the nicklist even though they are valid bot users - fix this
# - do a configurable 'reply on seen nick'
#####

### *** SETTINGS! ***
# filename of the file where nicks list will be saved
# (defaults to seen.nicks)
set seennicks {seen.nicks}
# save nicks each (this setting) minutes (defaults to 15
# minutes)
set nicksavetime 10
# check for expired users on every this much minutes
# this should be set to a reasonable value like one hour or
# one day or something like that (defaults to 60 minutes)
set expirechk 30
# time in hours for the nick that is NOT on the bot's
# userlist to expire. this keeps the seennicks file from
# getting huge (defaults to 720 hours -> 30 days)
set nickexpire 336
###

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# !!! DO NOT CHANGE ANYTHING BELOW THIS LINE !!!

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

###

set seenver "adbseen.tcl v1.9.2fr"

if {!([info exists seenpubf])} {set seenpubf "-"}

if {!([info exists seenmsgf])} {set seenmsgf "-"}

set nlist ""



# delete fake/existing userlist users from the seennicks list

proc seen_del_existing {uhand} {

  global nlist

  # delete nicks if the user exists in the userlist

  append fwho "+" $uhand

  set ind [lsearch -exact $nlist [string tolower $fwho]]

  set deld 0

  if {$ind != -1} {

    set nlist [lreplace $nlist $ind [expr $ind + 3]]

    return 1

  }

  return 0

}





# force nick update

proc force_seenupd {hand idx arg} {

  global seennicks

  if {[llength $arg] < 1} {

    #update all users

    putdcc $idx "Updating seen information for all users in the userlist..."

    set deld 0

    foreach uhand [userlist] {

      incr deld [seen_del_existing $uhand]

    }

    if {$deld} {

      putdcc $idx "Removed $deld nick(s) from nicks list that existed in the userlist."

    }

  } else {

    #update specified nicks

    foreach uhand $arg {

      seen_del_existing $uhand

    }

  }

  putdcc $idx "Update complete."

}





# update nick's status..

proc nick_upd {chan nick uhand how} {

  global nlist

  #set uhand [string tolower $uhand]

  if {$uhand!="*"} {

    # this user is a valid user

    setlaston $uhand

    setuser $uhand XTRA seenon $chan

    setuser $uhand XTRA seenhow $how

    # delete possible fake user entry in the nick list

    append fwho "-" $uhand

    set ind [lsearch -exact $nlist [string tolower $fwho]]

    if {$ind != -1} {

      set nlist [lreplace $nlist $ind [expr $ind + 3]]

    }

    seen_del_existing $uhand

    return 1

  } else {

    # this user is NOT a valid user..

    if {[validuser $nick]} {

      # ..but he's using the nick of one of the valid users!

      append mnick "-" [string tolower $nick]

    } else {

      # ..and he's using his own nick.. (this one will most probably only happen to $botnick)

      append mnick "+" [string tolower $nick]

    }

  }

  set timeon [unixtime]

  set ind [lsearch -exact $nlist $mnick]

  if {($ind >= 0)} {

    #found nick! replace it

    set nlist [lreplace $nlist [expr $ind + 1] [expr $ind + 3] $timeon $chan $how]

  } else {

    #nick nonexistant. append to the list

    lappend nlist $mnick $timeon $chan $how

  }

}





# save nicks

proc dcc_nick_save {hand idx arg} {

  global seennicks

  nick_save

  putdcc $idx "Nicks saved to file ${seennicks}"

}

proc nick_save {} {

  global seennicks nlist nicksavetime

  set f [open $seennicks w]

  puts $f $nlist

  close $f

  timer $nicksavetime "nick_save"

}





# delete expired users from the list

proc check_expired {} {

  global nickexpire expirechk nlist

  putlog "-Seen- Checking for expired users. The bot will not respond until it's finished."

  set total [expr [llength $nlist] - 1]

  set mtotal [expr $total / 4]

  set nulist ""

  set nrdel 0

  set ind 0

  set nrtot 0

  foreach ent $nlist {

    switch $ind {

      0 {

        set nik $ent

        set ind 1

      }

      1 {

        set loff $ent

        set ind 2

      }

      2 {

        set lchan $ent

        set ind 3

      }

      3 {

        if {[expr ([unixtime] - $loff) / 3600] < $nickexpire} {

        #hasn't yet expired, add to the nulist

        lappend nulist $nik $loff $lchan $ent

        } else {incr nrdel 1}

        set ind 0

      }

    }

  }

  set nlist $nulist

  if {$nrdel > 0} {

    putlog "-Seen- Deleted $nrdel expired nicks out of total $mtotal ([expr 100.0 * $nrdel / $mtotal]%)."

  }

  putlog "-Seen- Done. Next check will be done in $expirechk minutes."

  timer $expirechk "check_expired"

}





proc putseen {out isdcc text} {

  if {$isdcc} {

    putdcc $out $text

  } else {

    putserv "PRIVMSG $out :$text"

  }

}



# return how <who> left

proc adb_seengethow {who} {

  switch [user-get $who seenhow] {

    1 {

      return "*kicked*"

    }

    default {

      return "on"

    }

  }

}



# return 'one of my channels' if the channel

# is +secret

# return 'the channel'/'my party line' if the

# nick was on the same channel as the user is on

# return channel nick was last seen on otherwise

proc thechan {whochan userchan} {

  if {$whochan == "my party line"} {

    return "my party line"

  }

  if {[lsearch [channels] $whochan] == -1} {

    return $whochan

  }

  if {[string tolower $whochan] == [string tolower $userchan]} {

    return "this channel"

  }

  if {[lsearch [channel info $whochan] "+secret"] == -1} {

    return $whochan

  }

  return ""

}





# show when <who> was last on

proc adb_seen {channel nick uhost handle who isdcc} {

  global nlist botnick



  set unick ""

  if {$isdcc == 0} {

    if {[string compare $channel $nick] != 0} {

      append unick $nick ": "

    }

  }



  if {$who == ""} {

    putseen $channel $isdcc "${unick}Correct syntax is 'seen <nick>'"

    return 1

  }



  set who [string trim [lindex $who 0] ?]

  if {[string compare [string tolower $botnick] [string tolower $who]] == 0} {

    putseen $channel $isdcc "${unick}Sure, I guess you don't see me now - right ??"

    return 1

  }

  if {[string compare [string tolower $nick] [string tolower $who]] == 0} {

    putseen $channel $isdcc "${unick}Aren't you in here right now ?? :)"

    return 1

  }



  if {$unick==""} {

    #request via MSG!

    foreach chan [channels] {

      if {[onchan $who $chan]} {

        putseen $channel $isdcc "Hmm... Isn't $who on IRC right now ??"

        return 1

      }

      if {[onchansplit $who $chan]} {

        putseen $channel $isdcc "${who} was just on IRC, but got netsplit.. shame, huh?:)"

        return 1

      }

      foreach i [chanlist $chan] {

        set hand [finduser $i![getchanhost $i $chan]]

        if {($hand != "*") && ([string compare [string tolower $hand] [string tolower $who]] == 0)} {

          if {[onchansplit $i $chan]} {

            putseen $channel $isdcc "$i is ${who}, and $i was just on [thechan $chan $channel] but got netsplit.."

          } {

            putseen $channel $isdcc "$i is ${who}, and $i is on [thechan $chan $channel] right now!"

          }

          return 1

        }

      }

    }



  } else {

    #request via PUB!

    #check if the nick is on YOUR channel

    if {[onchansplit $who $channel]} {

      putseen $channel $isdcc "${unick}${who} was just here, but got netsplit.. shame, huh?:)"

      return 1

    }

    if {[onchan $who $channel]} {

      putseen $channel $isdcc "${unick}${who} is on the channel right now - look in front of you !!"

      return 1

    }

    foreach i [chanlist $channel] {

      set hand [finduser $i![getchanhost $i $channel]]

      if {($hand != "*") && ([string compare [string tolower $hand] [string tolower $who]] == 0)} {

        if {[onchansplit $i $channel]} {

          putseen $channel $isdcc "${unick}$i is ${who}, and $i was just here but got netsplit"

        } {

          putseen $channel $isdcc "${unick}$i is ${who}, and $i is on the channel right now!"

        }

        return 1

      }

    }



    #hmm.. obviously not. let's check if he's on other channels we're on

    set channel [string tolower $channel]

    foreach chan [channels] {

      if {[string compare [string tolower $chan] $channel] == 0} {

        #already did this channel (YOUR channel)

        continue

      }

      if {[onchansplit $who $chan]} {

        putseen $channel $isdcc "${unick}${who} was just on [thechan $chan $channel] but got netsplit.. shame, huh?:)"

        return 1

      }

      if {[onchan $who $chan]} {

        putseen $channel $isdcc "${unick}If I'm not mistaken ${who} is on [thechan $chan $channel] at the moment..."

        return 1

      }

      foreach i [chanlist $chan] {

        set hand [finduser $i![getchanhost $i $chan]]

        if {($hand != "*") && ([string compare [string tolower $hand] [string tolower $who]] == 0)} {

          if {[onchansplit $i $chan]} {

            putseen $channel $isdcc "${unick}$i is ${who}, and $i was just on [thechan $chan $channel] but got netsplit.."

          } {

            putseen $channel $isdcc "${unick}$i is ${who}, and $i is on [thechan $chan $channel] right now!"

          }

          return 1

        }

      }

    }

  }



  if {[hand2idx $who] >= 0} {

    if {[matchattr $handle p]} {

      putseen $channel $isdcc "${unick}$who is on my party line right now !!"

      return 1

    }

  }



  append fwho "-" $who

  set find [lsearch -exact $nlist [string tolower $fwho]]

  if {$find!=-1} {

    set ind $find

    set ending " I cannot guarantee that it really was ${who} though (different host than the one I have stored in my userlist) !!"

  } else {

    append rwho "+" $who

    set ind [lsearch -exact $nlist [string tolower $rwho]]

    set ending ""

  }

  if {$ind == -1} {

    if {[validuser $who]} {

      set last [getuser $who LASTON $channel]

      set seenon [thechan [getuser $who XTRA seenon] $channel]

      switch [getuser $who XTRA seenhow] {

        1 {

          set seenhow "*kicked*"

        }

        default {

          set seenhow ""

        }

      }

      if {$last == 0} {

        putseen $channel $isdcc "${unick}Sorry, but I haven't seen ${who} recently."

        return 1

      } else {

        if {$seenon != ""} {

                putseen $channel $isdcc "${unick}I last saw $who on $seenon - [tdiff [unixtime] $last]ago."

                } else {

                putseen $channel $isdcc "${unick}I last saw $who [tdiff [unixtime] $last]ago."

                }

        return 1

      }

    }

    putseen $channel $isdcc "${unick}I haven't seen anyone with the nick - ${who}."

    return 1

  } else {

    set last [lindex $nlist [expr $ind + 1]]

    set seenon [thechan [lindex $nlist [expr $ind + 2]] $channel]

    switch [lindex $nlist [expr $ind + 3]] {

      1 {

        set seenhow "*kicked*"

      }

      default {

        set seenhow ""

      }

    }

        if {($seenhow != "")&&($seenon != "")} {

                putseen $channel $isdcc "${unick}I last saw $who on $seenon - $seenhow - [tdiff [unixtime] $last]ago."

                } else {

                putseen $channel $isdcc "${unick}I last saw $who [tdiff [unixtime] $last]ago."

                }

    return 1

  }

}





# time difference

proc tdiff {time2 time1} {

  set ltime [expr $time2 - $time1]

  set seconds [expr $ltime % 60]

  set ltime [expr ($ltime - $seconds) / 60]

  set minutes [expr $ltime % 60]

  set ltime [expr ($ltime - $minutes) / 60]

  set hours [expr $ltime % 24]

  set days [expr ($ltime - $hours) / 24]



  set result ""



  if {$days} {

    append result "$days "

    if {$days == 1} {

      append result "day "

    } else {

      append result "days "

    }

  }

  if {$hours} {

    append result "$hours "

    if {$hours == 1} {

      append result "hour "

    } else {

      append result "hours "

    }

  }

  if {$minutes} {

    append result "$minutes "

    if {$minutes == 1} {

      append result "minute "

    } else {

      append result "minutes "

    }

  }

  if {$seconds} {

    append result " $seconds "

    if {$seconds == 1} {

      append result "second "

    } else {

      append result "seconds "

    }

  }

  return $result

}





proc dcc_seen {hand idx arg} {

  adb_seen $idx $hand "" $hand $arg 1

}

bind dcc - seen dcc_seen



proc pub_seen {nick uhost hand channel who} {

  adb_seen $channel $nick $uhost $hand $who 0

}

bind pub - seen pub_seen



proc msg_seen {nick uhost hand who} {

  adb_seen $nick $nick $uhost $hand $who 0

}

bind msg - seen msg_seen



proc seen_join {nick uhost hand channel} {

  nick_upd $channel $nick $hand 0

}

bind join - * seen_join



proc seen_part {nick uhost hand channel} {

  nick_upd $channel $nick $hand 0

}

bind part - * seen_part



proc seen_sign {nick uhost hand channel reason} {

  nick_upd $channel $nick $hand 0

}

bind sign - * seen_sign



proc seen_nickch {nick uhost hand channel newnick} {

  nick_upd $channel $nick $hand 0

  nick_upd $channel $newnick $hand 0

}

bind nick - * seen_nickch



proc seen_kick {nick uhost hand channel kicked reason} {

  set hand [nick2hand $kicked $channel]

  nick_upd $channel $kicked $hand 1

}

bind kick - * seen_kick



proc seen_chof {hand idx} {

  nick_upd "my party line" $hand $hand 0

}

bind chof - * seen_chof



#for testing/emergency nick save only

bind dcc m savenicks dcc_nick_save



#force deletion of nicks in the nickfile that are in the userlist

#(this command should be issued if new users are added to the bot's

#userlist)

bind dcc m seenupd force_seenupd



# script initialization

putlog "$seenver loaded"

# set defaults

if {!([info exists seennicks])} { set seennicks {seen.nicks} }

if {!([info exists nicksavetime])} { set nicksavetime 15 }

if {!([info exists nickexpire])} { set nickexpire 720 }

if {!([info exists expirechk])} { set expirechk 60 }

if [file exists $seennicks] {

  set f [open $seennicks r]

  if {[gets $f nlist] != -1} {

    if {[expr [llength $nlist] % 4] != 0} {

      putlog "-Seen- Invalid nicks list.. Clearing nicks list."

      set nlist ""

    }

  } else {

    putlog "-Seen- Invalid data file. Nicks list not loaded."

    set nlist ""

  }

  close $f

}

# update users on the channel

foreach chan [channels] {

  foreach n [chanlist $chan] {

    set hand [nick2hand $n $chan]

    nick_upd $chan $n $hand 0

  }

}

nick_save

check_expired

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us