-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbetterseen.tcl
1023 lines (784 loc) · 32 KB
/
betterseen.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
# $Id: seenster1.0.tcl 2005/05/27 04:20:00 Seanster Exp $
###############################################################################
# seenster for eggdrop bots
# Copyright (C) 2005 Sean McLaughlin
#
# This program is covered by the GPL, please refer the to LICENCE file in the
# distribution.
###############################################################################
#./configure --with-tcl=/usr/local/lib --with-tclinclude=/usr/local/include -with-mysql-include=/usr/local/mysql/include/mysql/ --with-mysql-lib=/usr/local/mysql/lib/mysql/
# load the extension
# most people should get away with the package command if their server is setup right
# If your main bot's server has broken TCL, you may need the line below it
# Use only one!
#
package require mysqltcl
#load /usr/local/lib/mysqltcl-3.01/libmysqltcl3.01.so
#
# connect to database
#
set db_handle [mysqlconnect -host localhost -user faqbot -password password -db vox_seen]
# IMPORTANT! Use this bot command to enable/disable individual channels
# .chanset #channel [+/-]seenster
# maximum number of seens to show in channel when searching before switching to /msg'ing the user
set seen_seenmax 1
# maximum number of seens to report
set seen_seenmaxmax 1
# url to site CHANGE ME (use blank if you're not using the PHP script)
set php_page ""
# set php_page "http://www.xxx.ca/seenster/"
###############################################################################
### bind commands CHANGE as needed
#bind pub "m|ov" !addquote quote_add
###############################################################################
bind pub "-|-" .seen seen_seen
bind pub "-|-" .aseen seen_aseen
#bind pub "-|-" .lastseen seen_seen
#bind pub "-|-" .checkquit seen_quit
bind pub "-|-" .left seen_quit
#bind pub "-|-" .lastspoke seen_spoke
bind pub "-|-" .spoke seen_spoke
bind pub "-|-" .said seen_spoke
#bind pub "-|-" .lasttopic seen_topic
#bind pub "-|-" .topic seen_topic
#bind pub "-|-" .lastactn seen_actn
bind pub "-|-" .actn seen_actn
#bind pub "-|-" .lastbong seen_bong
bind pub "-|-" .bong seen_bong
#bind pub "-|-" .seenversion seen_version
bind pub "-|-" .seenhelp seen_help
bind join "-|-" * irc_join
bind part "-|-" * irc_part
bind sign "-|-" * irc_sign
bind splt "-|-" * irc_splt
bind rejn "-|-" * irc_rejn
bind kick "-|-" * irc_kick
bind nick "-|-" * irc_nick
bind topc "-|-" * irc_topc
bind ctcp - "ACTION" irc_actn
bind pubm "-|-" * irc_said
#bind away "-|-" * irc_away
# a user with this flag(s) can't use the script at all
set seen_noflags "Q|Q"
###############################################################################
### code starts here (no need to edit stuff below)
###############################################################################
set seen_version "20050527"
#add setting to channel
setudef flag seenster
###############################################################################
### user commands start here
###
################################################################################
################################################################################
# seen_seen
# !seen <nick> [max_history]
# Find the last database entry for nick
# The first 2 (seen_seenmax) are listed in the channel. The rest are /msg'd to
# you up to 20 (seen_seenmaxmax).
#
# Note this is a SQL search, so use % as the wildcard (instead of *)
# The script automatically puts %s around your text when searching.
################################################################################
proc seen_seen { nick host handle channel text } {
global db_handle php_page seen_noflags seen_seenmax seen_seenmaxmax
set output ""
# check that seenster is enabled for the channel
if {![channel get $channel seenster]} {
return 0
}
# check if the user is denied seen rights
# if [matchattr $handle $seen_noflags] {
# return 0
# }
if {$text == ""} {
puthelp "PRIVMSG $channel :Use: !seen <nick>"
return 0
}
set where_clause "AND channel='$channel'"
# if [regexp -- "--?all " $text matches skip1]
# {
# set where_clause ""
# regsub -- $matches $text "" text
# }
# if [regexp -- {--?c(hannel)?( |=)([^ ]+)} $text matches skip1 skip2 newchan]
# {
# set where_clause "AND channel='[mysqlescape $newchan]'"
# regsub -- $matches $text "" text
# }
set limit [mysqlescape $seen_seenmaxmax]
# if [regexp -- {--?count( |=)([^ ]+)} $text matches skip1 count]
# {
# set limit [mysqlescape $count]
# regsub -- $matches $text "" text
# }
# if [regexp -- {-n( )?([^ ]+)} $text matches skip1 count]
# {
# set limit [mysqlescape $count]
# regsub -- $matches $text "" text
# }
set sql "SELECT * FROM vox_seen.seen WHERE nick LIKE '%[mysqlescape $text]%' $where_clause ORDER BY ts DESC LIMIT $limit"
putloglev d * "seenster: executing $sql"
if {[mysqlsel $db_handle $sql] > 0} {
set count 0
mysqlmap $db_handle {m_id m_nick m_host m_ts m_channel m_action m_text} {
if {$count == $seen_seenmaxmax} {
break
}
if {$count == $seen_seenmax } {
puthelp "PRIVMSG $nick :Rest of matches for your search '$text' follow in private:"
}
# set details $m_text
# if {$details == ""} {
# set details "."
# }
# [format_record $m_id $m_nick $m_host $m_ts $m_channel $m_action $m_text]
# set output [format_record 10 sean hereathtere 9922343 #cutlass join reason]
# set output "$m_id $m_nick $m_host $m_ts $m_channel $m_action $details"
set output [format_record $m_id $m_nick $m_host $m_ts $m_channel $m_action $m_text]
if {$count < $seen_seenmax} {
puthelp "PRIVMSG $channel :\[\002$nick\002\] $output"
} else {
puthelp "PRIVMSG $nick :\[\002$nick\002\] $output"
}
incr count
}
# with LIMIT set, there will never be any remaining records to count
# according to my tests anyway
## set remaining [mysqlresult $db_handle rows?]
## if {$remaining > 0} {
## regsub "#" $channel "" chan
## if {$php_page != ""} {
## puthelp "PRIVMSG $channel :(Plus $remaining more matches: $php_page?filter=${text}&channel=${chan}&search=search)"
## } else {
## puthelp "PRIVMSG $channel :Plus $remaining other matches"
## }
## } else {}
if {$count == 1} {
#puthelp "PRIVMSG $channel :(All of 1 match)"
} else {
puthelp "PRIVMSG $nick :(All of $count matches)"
}
} else {
puthelp "PRIVMSG $channel :No matches"
}
}
################################################################################
# seen_aseen
# !seen <nick> [max_history]
# seen for _all_ channels
################################################################################
proc seen_aseen { nick host handle channel text } {
global db_handle php_page seen_noflags seen_seenmax seen_seenmaxmax
set output ""
# check that seenster is enabled for the channel
if {![channel get $channel seenster]} {
return 0
}
if {$text == ""} {
puthelp "PRIVMSG $channel :Use: !seen <nick>"
return 0
}
set limit [mysqlescape $seen_seenmaxmax]
set sql "SELECT * FROM vox_seen.seen WHERE nick LIKE '%[mysqlescape $text]%' ORDER BY ts DESC LIMIT $limit"
putloglev d * "seenster: executing $sql"
if {[mysqlsel $db_handle $sql] > 0} {
set count 0
mysqlmap $db_handle {m_id m_nick m_host m_ts m_channel m_action m_text} {
if {$count == $seen_seenmaxmax} {
break
}
if {$count == $seen_seenmax } {
puthelp "PRIVMSG $nick :Rest of matches for your search '$text' follow in private:"
}
set output [format_record $m_id $m_nick $m_host $m_ts $m_channel $m_action $m_text]
if {$count < $seen_seenmax} {
puthelp "PRIVMSG $channel :\[\002$nick\002\] $output"
} else {
puthelp "PRIVMSG $nick :\[\002$nick\002\] $output"
}
incr count
}
if {$count == 1} {
#puthelp "PRIVMSG $channel :(All of 1 match)"
} else {
puthelp "PRIVMSG $nick :(All of $count matches)"
}
} else {
puthelp "PRIVMSG $channel :No matches"
}
}
################################################################################
# seen_quit
# !seen <nick> [max_history]
# Find the last database entry for nick
# The first 2 (seen_seenmax) are listed in the channel. The rest are /msg'd to
# you up to 20 (seen_seenmaxmax).
#
# Note this is a SQL search, so use % as the wildcard (instead of *)
# The script automatically puts %s around your text when searching.
################################################################################
proc seen_quit { nick host handle channel text } {
global db_handle php_page seen_noflags seen_seenmax seen_seenmaxmax
set output ""
# check that seenster is enabled for the channel
if {![channel get $channel seenster]} {
return 0
}
# check if the user is denied seen rights
# if [matchattr $handle $seen_noflags] {
# return 0
# }
set qnick $text
if {$text == ""} {
set qnick $nick
}
set where_clause "AND channel='$channel' AND (action='part' OR action='quit' OR action='kick' OR action='splt') "
# if [regexp -- "--?all " $text matches skip1]
# {
# set where_clause ""
# regsub -- $matches $text "" text
# }
# if [regexp -- {--?c(hannel)?( |=)([^ ]+)} $text matches skip1 skip2 newchan]
# {
# set where_clause "AND channel='[mysqlescape $newchan]'"
# regsub -- $matches $text "" text
# }
set limit [mysqlescape $seen_seenmaxmax]
# if [regexp -- {--?count( |=)([^ ]+)} $text matches skip1 count]
# {
# set limit [mysqlescape $count]
# regsub -- $matches $text "" text
# }
# if [regexp -- {-n( )?([^ ]+)} $text matches skip1 count]
# {
# set limit [mysqlescape $count]
# regsub -- $matches $text "" text
# }
set sql "SELECT * FROM vox_seen.seen WHERE nick LIKE '%[mysqlescape $qnick]%' $where_clause ORDER BY ID DESC LIMIT $limit"
putloglev d * "seenster: executing $sql"
if {[mysqlsel $db_handle $sql] > 0} {
set count 0
mysqlmap $db_handle {m_id m_nick m_host m_ts m_channel m_action m_text} {
if {$count == $seen_seenmaxmax} {
break
}
if {$count == $seen_seenmax } {
puthelp "PRIVMSG $nick :Rest of matches for your search '$text' follow in private:"
}
# set details $m_text
# if {$details == ""} {
# set details "."
# }
# [format_record $m_id $m_nick $m_host $m_ts $m_channel $m_action $m_text]
# set output [format_record 10 sean hereathtere 9922343 #cutlass join reason]
# set output "$m_id $m_nick $m_host $m_ts $m_channel $m_action $details"
set output [format_record $m_id $m_nick $m_host $m_ts $m_channel $m_action $m_text]
if {$count < $seen_seenmax} {
puthelp "PRIVMSG $channel :\[\002$nick\002\] $output"
} else {
puthelp "PRIVMSG $nick :\[\002$nick\002\] $output"
}
incr count
}
# with LIMIT set, there will never be any remaining records to count
# according to my tests anyway
## set remaining [mysqlresult $db_handle rows?]
## if {$remaining > 0} {
## regsub "#" $channel "" chan
## if {$php_page != ""} {
## puthelp "PRIVMSG $channel :(Plus $remaining more matches: $php_page?filter=${text}&channel=${chan}&search=search)"
## } else {
## puthelp "PRIVMSG $channel :Plus $remaining other matches"
## }
## } else {}
if {$count == 1} {
#puthelp "PRIVMSG $channel :(All of 1 match)"
} else {
puthelp "PRIVMSG $nick :(All of $count matches)"
}
} else {
puthelp "PRIVMSG $channel :No matches"
}
}
################################################################################
# seen_spoke
# !seen <nick> [max_history]
# Find the last database entry for nick
# The first 2 (seen_seenmax) are listed in the channel. The rest are /msg'd to
# you up to 20 (seen_seenmaxmax).
#
# Note this is a SQL search, so use % as the wildcard (instead of *)
# The script automatically puts %s around your text when searching.
################################################################################
proc seen_spoke { nick host handle channel text } {
global db_handle php_page seen_noflags seen_seenmax seen_seenmaxmax
set output ""
# check that seenster is enabled for the channel
if {![channel get $channel seenster]} {
return 0
}
set qnick $text
if {$text == ""} {
set qnick $nick
}
set where_clause "AND channel='$channel' AND (action='said' OR action='actn' OR action='topc') "
set limit [mysqlescape $seen_seenmaxmax]
set sql "SELECT * FROM vox_seen.seen WHERE nick LIKE '%[mysqlescape $qnick]%' $where_clause ORDER BY ID DESC LIMIT $limit"
putloglev d * "seenster: executing $sql"
if {[mysqlsel $db_handle $sql] > 0} {
set count 0
mysqlmap $db_handle {m_id m_nick m_host m_ts m_channel m_action m_text} {
if {$count == $seen_seenmaxmax} {
break
}
if {$count == $seen_seenmax } {
puthelp "PRIVMSG $nick :Rest of matches for your search '$text' follow in private:"
}
set output [format_record $m_id $m_nick $m_host $m_ts $m_channel $m_action $m_text]
if {$count < $seen_seenmax} {
puthelp "PRIVMSG $channel :\[\002$nick\002\] $output"
} else {
puthelp "PRIVMSG $nick :\[\002$nick\002\] $output"
}
incr count
}
if {$count == 1} {
#puthelp "PRIVMSG $channel :(All of 1 match)"
} else {
puthelp "PRIVMSG $nick :(All of $count matches)"
}
} else {
puthelp "PRIVMSG $channel :No matches"
}
}
################################################################################
# seen_topic
# !seen <nick> [max_history]
# Find the last database entry for nick
# The first 2 (seen_seenmax) are listed in the channel. The rest are /msg'd to
# you up to 20 (seen_seenmaxmax).
#
# Note this is a SQL search, so use % as the wildcard (instead of *)
# The script automatically puts %s around your text when searching.
################################################################################
proc seen_topic { nick host handle channel text } {
global db_handle php_page seen_noflags seen_seenmax seen_seenmaxmax
set output ""
# check that seenster is enabled for the channel
if {![channel get $channel seenster]} {
return 0
}
set qnick $text
if {$text == ""} {
set where_clause "WHERE "
} else {
set where_clause "WHERE nick LIKE '%[mysqlescape $qnick]%' AND "
}
set where_clause [concat $where_clause "channel='$channel' AND action='topc' "]
set limit [mysqlescape $seen_seenmaxmax]
set sql "SELECT * FROM vox_seen.seen $where_clause ORDER BY ID DESC LIMIT $limit"
putloglev d * "seenster: executing $sql"
if {[mysqlsel $db_handle $sql] > 0} {
set count 0
mysqlmap $db_handle {m_id m_nick m_host m_ts m_channel m_action m_text} {
if {$count == $seen_seenmaxmax} {
break
}
if {$count == $seen_seenmax } {
puthelp "PRIVMSG $nick :Rest of matches for your search '$text' follow in private:"
}
set output [format_record $m_id $m_nick $m_host $m_ts $m_channel $m_action $m_text]
if {$count < $seen_seenmax} {
puthelp "PRIVMSG $channel :\[\002$nick\002\] $output"
} else {
puthelp "PRIVMSG $nick :\[\002$nick\002\] $output"
}
incr count
}
if {$count == 1} {
#puthelp "PRIVMSG $channel :(All of 1 match)"
} else {
puthelp "PRIVMSG $nick :(All of $count matches)"
}
} else {
puthelp "PRIVMSG $channel :No matches"
}
}
################################################################################
# seen_actn
# !seen <nick> [max_history]
# Find the last database entry for nick
# The first 2 (seen_seenmax) are listed in the channel. The rest are /msg'd to
# you up to 20 (seen_seenmaxmax).
#
# Note this is a SQL search, so use % as the wildcard (instead of *)
# The script automatically puts %s around your text when searching.
################################################################################
proc seen_actn { nick host handle channel text } {
global db_handle php_page seen_noflags seen_seenmax seen_seenmaxmax
set output ""
# check that seenster is enabled for the channel
if {![channel get $channel seenster]} {
return 0
}
if {$text == ""} {
set where_clause "WHERE "
} else {
set where_clause "WHERE text LIKE '%[mysqlescape $text]%' AND "
}
set where_clause [concat $where_clause "channel='$channel' AND action='actn' "]
set limit [mysqlescape $seen_seenmaxmax]
set sql "SELECT * FROM vox_seen.seen $where_clause ORDER BY ID DESC LIMIT $limit"
putloglev d * "seenster: executing $sql"
if {[mysqlsel $db_handle $sql] > 0} {
set count 0
mysqlmap $db_handle {m_id m_nick m_host m_ts m_channel m_action m_text} {
if {$count == $seen_seenmaxmax} {
break
}
if {$count == $seen_seenmax } {
puthelp "PRIVMSG $nick :Rest of matches for your search '$text' follow in private:"
}
set output [format_record $m_id $m_nick $m_host $m_ts $m_channel $m_action $m_text]
if {$count < $seen_seenmax} {
puthelp "PRIVMSG $channel :\[\002$nick\002\] $output"
} else {
puthelp "PRIVMSG $nick :\[\002$nick\002\] $output"
}
incr count
}
if {$count == 1} {
#puthelp "PRIVMSG $channel :(All of 1 match)"
} else {
puthelp "PRIVMSG $nick :(All of $count matches)"
}
} else {
puthelp "PRIVMSG $channel :No matches"
}
}
################################################################################
# seen_bong
# !seen <nick> [max_history]
# Find the last database entry for nick
# The first 2 (seen_seenmax) are listed in the channel. The rest are /msg'd to
# you up to 20 (seen_seenmaxmax).
#
# Note this is a SQL search, so use % as the wildcard (instead of *)
# The script automatically puts %s around your text when searching.
################################################################################
proc seen_bong { nick host handle channel text } {
global db_handle php_page seen_noflags seen_seenmax seen_seenmaxmax
set output ""
# check that seenster is enabled for the channel
if {![channel get $channel seenster]} {
return 0
}
set qnick $text
if {$text == ""} {
set where_clause "WHERE "
} else {
set where_clause "WHERE nick LIKE '%[mysqlescape $qnick]%' AND "
}
set where_clause [concat $where_clause "channel='$channel' AND action='actn' AND text like '%bong%' "]
set limit [mysqlescape $seen_seenmaxmax]
set sql "SELECT * FROM vox_seen.seen $where_clause ORDER BY ID DESC LIMIT $limit"
putloglev d * "seenster: executing $sql"
if {[mysqlsel $db_handle $sql] > 0} {
set count 0
mysqlmap $db_handle {m_id m_nick m_host m_ts m_channel m_action m_text} {
if {$count == $seen_seenmaxmax} {
break
}
if {$count == $seen_seenmax } {
puthelp "PRIVMSG $nick :Rest of matches for your search '$text' follow in private:"
}
set output [format_record $m_id $m_nick $m_host $m_ts $m_channel $m_action $m_text]
if {$count < $seen_seenmax} {
puthelp "PRIVMSG $channel :\[\002$nick\002\] $output"
} else {
puthelp "PRIVMSG $nick :\[\002$nick\002\] $output"
}
incr count
}
if {$count == 1} {
#puthelp "PRIVMSG $channel :(All of 1 match)"
} else {
puthelp "PRIVMSG $nick :(All of $count matches)"
}
} else {
puthelp "PRIVMSG $channel :No matches"
}
}
################################################################################
# seen_version
# !seenversion
# Gives the version of the script
################################################################################
proc seen_version { nick host handle channel text } {
global seen_version seen_noflags
# if [matchattr $handle $seen_noflags] { return 0 }
puthelp "PRIVMSG $channel :This is seenster version $seen_version by Seanster http://www.Seanster.com/seenster "
return 0
}
################################################################################
# seen_help
# !seenhelp
# Handle help requests
################################################################################
proc seen_help { nick host handle channel text } {
global seen_noflags
# if [matchattr $handle $seen_noflags] { return 0 }
puthelp "PRIVMSG $nick :Commands for the seenster script:"
puthelp "PRIVMSG $nick : !seen <nick> - looks up the last record for a nickname"
puthelp "PRIVMSG $nick : !quit {nick} - fetches the last part/quit/split, nick optional"
puthelp "PRIVMSG $nick : !spoke {nick} - fetches the last said/actn/topc, nick optional"
puthelp "PRIVMSG $nick : !topic {nick} - fetches the last topc, nick optional"
puthelp "PRIVMSG $nick : !actn {nick} - fetches the last actn, nick optional"
puthelp "PRIVMSG $nick : !seenversion - version information"
puthelp "PRIVMSG $nick : !seenhelp - this help text"
puthelp "PRIVMSG $nick : (End of help)"
return 0
}
################################################################################
### irc notices start here
################################################################################
proc irc_join {nick uhost hand chan} {seen_add $nick [list $uhost] [unixtime] $chan "join" ""}
proc irc_part {nick uhost hand chan reason} {seen_add $nick [list $uhost] [unixtime] $chan "part" "[split $reason]"}
proc irc_sign {nick uhost hand chan reason} {seen_add $nick [list $uhost] [unixtime] $chan "quit" "[split $reason]"}
proc irc_splt {nick uhost hand chan} {seen_add $nick [list $uhost] [unixtime] $chan "splt" ""}
proc irc_rejn {nick uhost hand chan} {seen_add $nick [list $uhost] [unixtime] $chan "rejn" ""}
proc irc_kick {nick uhost hand chan knick reason} {seen_add $knick [getchanhost $knick $chan] [unixtime] $chan "kick" "[list $nick] [list $reason]"}
proc irc_nick {nick uhost hand chan newnick} {set time [unixtime] ; seen_add $nick [list $uhost] [expr $time -1] $chan "nick" "[list $newnick]" ; seen_add $newnick [list $uhost] $time $chan "rnck" "[list $nick]"}
proc irc_topc {nick uhost hand chan topic} {seen_add $nick [list $uhost] [unixtime] $chan "topc" $topic}
proc irc_actn { nick uhost hand dest keyword text } {
if {[string index $dest 0] != "#"} {
return 0
}
seen_add $nick [list $uhost] [unixtime] $dest "actn" [string trim $text {}]
}
proc irc_said {nick uhost hand chan text} {seen_update $nick [list $uhost] [unixtime] $chan "said" $text}
#proc irc_away {bot idx msg} {seen_update $hand [join [string trim [lindex $old 1] ()]] [unixtime] $bot away [bs_filt [join $msg]]}
################################################################################
# seen_update
# {id nick host ts channel action text }
################################################################################
proc seen_update { nick host ts channel action text } {
global db_handle seen_noflags
# check that seenster is enabled for the channel
if {![channel get $channel seenster]} {
return 0
}
set sql "UPDATE vox_seen.seen SET "
append sql "host='$host', "
append sql "ts='$ts', "
set text [mysqlescape $text]
append sql "text='$text' "
append sql "WHERE nick='$nick' AND channel='$channel' AND action='said' ORDER BY ID DESC LIMIT 1"
putloglev d * "seenster: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result < 1} {
# no rows affected, insert instead
seen_add $nick $host $ts $channel $action $text
} else {
#puthelp "PRIVMSG $channel :seen said updated"
}
}
################################################################################
# seen_add
# {id nick host ts channel action text }
################################################################################
proc seen_add { nick host ts channel action text } {
global db_handle seen_noflags
# check that seenster is enabled for the channel
if {![channel get $channel seenster]} {
return 0
}
# check if the user is denied seen rights
# if [matchattr $handle $seen_noflags] {
# return 0
# }
set sql "INSERT INTO vox_seen.seen VALUES(null, "
append sql "'$nick', "
append sql "'$host', "
append sql "'$ts', "
append sql "'$channel', "
append sql "'$action', "
set text [mysqlescape $text]
append sql "'$text')"
putloglev d * "seenster: executing $sql"
set result [mysqlexec $db_handle $sql]
if {$result != 1} {
putloglev d * "seenster: An error occurred with the sql : $result"
} else {
#set id [mysqlinsertid $db_handle]
#puthelp "PRIVMSG $channel :seen added"
}
}
################################################################################
# format_record
################################################################################
proc format_record { m_id m_nick m_host m_ts m_channel m_action m_text } {
set output ""
switch -- $m_action {
part {
#set reason $m_text
#if {$reason == ""} {set reason "."} {set reason " stating \"$reason\"."}
set output [concat $m_nick ($m_host) was last seen parting $m_channel [stamp_to_string $m_ts] ago ($m_text)]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
set output [concat $output - $m_nick is currently on the channel]
}
}
}
quit {
set output [concat $m_nick ($m_host) was last seen quitting from $m_channel [stamp_to_string $m_ts] ago stating ($m_text)]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
set output [concat $output - $m_nick is currently on the channel]
}
}
}
kick {
set output [concat $m_nick ($m_host) was last seen being kicked from $m_channel by [lindex $m_text 0] [stamp_to_string $m_ts] ago with the reason ([join [lrange $m_text 1 end]])]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
set output [concat $output - $m_nick is currently on the channel]
}
}
}
rnck {
set output [concat $m_nick ($m_host) was last seen changing nicks from $m_text on $m_channel [stamp_to_string $m_ts] ago]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
set output [concat $output - $m_nick is still there]
} {
set output [concat $output - I don't see $m_nick now, though]
}
}
}
nick {
set output [concat $m_nick ($m_host) was last seen changing nicks to $m_text on $m_channel [stamp_to_string $m_ts] ago]
if {[validchan $m_channel]} {
if {[onchan $m_text $m_channel]} {
set output [concat $output - $m_text is still there]
} {
set output [concat $output - I don't see $m_text now, though]
}
}
}
splt {
set output [concat $m_nick ($m_host) was last seen parting $m_channel due to a split [stamp_to_string $m_ts] ago ($m_text)]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
set output [concat $output - $m_nick is currently on the channel]
}
}
}
rejn {
set output [concat $m_nick ($m_host) was last seen rejoining $m_channel from a split [stamp_to_string $m_ts] ago ($m_text)]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
#set output [concat $output - $m_nick is still there]
} {
set output [concat $output - I don't see $m_nick now, though]
}
}
}
join {
set output [concat $m_nick ($m_host) was last seen joining $m_channel [stamp_to_string $m_ts] ago]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
#set output [concat $output - $m_nick is still there]
} {
set output [concat $output - I don't see $m_nick now, though]
}
}
}
away {
set reason $m_text]
if {$reason == ""} {
set output [concat $m_nick ($m_host) was last seen returning to life on $m_channel [stamp_to_string $m_ts] ago]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
#set output [concat $output - $m_nick is still there]
} {
set output [concat $output - I don't see $m_nick now, though]
}
}
} {
set output [concat $m_nick ($m_host) was last seen being marked as away ($reason) on $m_channel [stamp_to_string $m_ts] ago]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
#set output [concat $output - $m_nick is still there]
} {
set output [concat $output - I don't see $m_nick now, though]
}
}
}
}
back {
set output [concat $m_nick ($m_host) was last seen returning to life on $m_channel [stamp_to_string $m_ts] ago stating ($m_text)]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
#set output [concat $output - $m_nick is still there]
} {
set output [concat $output - I don't see $m_nick now, though]
}
}
}
topc {
set output [concat $m_nick ($m_host) was seen on $m_channel [stamp_to_string $m_ts] ago changing the topic to ($m_text)]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
#set output [concat $output - $m_nick is still there]
} {
set output [concat $output - I don't see $m_nick now, though]
}
}
}
actn {
if { [string first bong [string tolower $m_text]] >= 0 } {
set output [concat $m_nick ($m_host) was seen taking a bong hit on $m_channel [stamp_to_string $m_ts] ago saying ($m_nick $m_text)]
} else {
set output [concat $m_nick ($m_host) was seen acting out on $m_channel [stamp_to_string $m_ts] ago saying ($m_nick $m_text)]
}
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
#set output [concat $output - $m_nick is still there]
} {
set output [concat $output - I don't see $m_nick now, though]
}
}
}
said {
set output [concat $m_nick ($m_host) was seen on $m_channel [stamp_to_string $m_ts] ago stating ($m_text)]
if {[validchan $m_channel]} {
if {[onchan $m_nick $m_channel]} {
#set output [concat $output - $m_nick is still there]
} {
set output [concat $output - I don't see $m_nick now, though]
}
}
}
}
return $output
}
################################################################################
# This is equiv to mIRC's $duration() function
################################################################################
proc stamp_to_string { stamp } {
set years 0 ; set days 0 ; set hours 0 ; set mins 0
set time [expr [unixtime] - $stamp]