Skip to content

Commit fdd382c

Browse files
authored
Fix / improve various searchbot trigger issues (#81)
Most common issue was search results not being autoaccepted.
1 parent 7d5ecbf commit fdd382c

File tree

1 file changed

+72
-29
lines changed

1 file changed

+72
-29
lines changed

dlFilter.mrc

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,13 @@ dlFilter uses the following code from other people:
6161
DCC RESUME doesn't seem to work properly.
6262
DCC RESUME should start again from the beginning if file is already fully downloaded.
6363
64-
Remove DLF.sbrequests/DLF.sbcurrentreqs for network#channel on part/quit/join (so that we get a list of bots every time we join and don't have a stale list)
6564
Reset stats for a channel on JOIN.
6665
Sort out spaces in private DCC Send messages
6766
If "CRC(xxxxx)" is in the DCC Send Notice then when file completes, check the CRC is correct and flag if not.
6867
If Op, option to highlight to self or other ops or ban user after x spam messages / reports from other ops.
6968
If user disables or unloads, remove stats from channel titles.
7069
Add option for showing parts and joins etc. for anyone who has spoken in channel (non-filtered messages)
7170
or anyone who user has communicated with or notify users or users who were ops / hops / voiced when they last parted/quit.
72-
Tracking search bot triggers needs improving to handle parts and joins.
73-
If channel joined has mode +d (can't send for 30s), don't send e.g. searchbot trigger request for 30s.
7471
7572
Ideas for possible future enhancements
7673
Create pop-up box option for channels to allow people to cut and paste a line which should be filtered but isn't and create a gitreports call.
@@ -176,6 +173,11 @@ dlFilter uses the following code from other people:
176173
Query for searchbots if search is done for trigger not in table (to avoid blocked response files).
177174
Additional filters.
178175
Additional menu items.
176+
Fix search responses not being autoaccepted. Triggers not being requested because @search-Triggers sent too early in channel with mode +d talk delay.
177+
Remove search triggers when you leave channel so that they are re-requested when you join in case list has changed.
178+
Re-request search triggers if nick search* joins or @search* called and nick/trigger is not in table.
179+
Fix handling of self join / part calling routines twice.
180+
Fix dlf.watch for quit server response.
179181
180182
*/
181183

@@ -436,27 +438,27 @@ on ^*:join:#: {
436438
if ($1-) %txt = : $1-
437439
if ($shortjoinsparts) %joins = Joins:
438440
else %joined = has joined $chan $+ %txt
439-
DLF.Event.Join %joins $nick $br($address) %joined %txt
441+
if ($nick !== $me) DLF.Event.Join %joins $nick $br($address) %joined %txt
442+
else DLF.Event.MeJoin $1-
443+
if (search* iswm $nick) DLF.SearchBot.GetTriggers $1 $nick
440444
}
441445

442-
on me:*:join:#: {
443-
DLF.Event.MeJoin $1-
444-
}
446+
; raw 324 Channel mode response
447+
raw 324:*: { DLF.SearchBot.MeJoin $2- }
445448

446-
raw 366:*: {
447-
DLF.Event.MeJoinComplete $1-
448-
}
449+
; raw 324 Channel user list complete
450+
raw 366:*: { DLF.Event.MeJoinComplete $1- }
449451

450452
on ^*:part:#: {
451453
var %txt, %parts, %hasleft
452454
if ($1-) %txt = $br($1-)
453455
if ($shortjoinsparts) %parts = Parts:
454456
else %hasleft = has left $chan %txt
455-
DLF.Event.Leave %parts $nick $br($address) %hasleft %txt
457+
var %msg %parts $nick $br($address) %hasleft %txt
458+
if ($nick !== $me) DLF.Event.Leave %msg
459+
else DLF.Event.MeLeave %msg
456460
}
457461

458-
on me:*:part:#: { DLF.Event.MeLeave $1- }
459-
460462
on ^*:kick:#: {
461463
var %txt, %addr, %fromchan
462464
if ($1-) var %txt $br($1-)
@@ -480,11 +482,6 @@ on ^*:quit: {
480482
DLF.Event.Quit $nick %quits $nick $br($address) %quit %txt
481483
}
482484

483-
; Not sure that ever triggers - when you quit ON DISCONNECT is called
484-
on me:*:quit: {
485-
DLF.Event.Disconnect $1-
486-
}
487-
488485
on *:connect: {
489486
DLF.Event.MeConnect $1-
490487
}
@@ -874,6 +871,7 @@ alias -l DLF.Event.Leave {
874871
alias -l DLF.Event.MeLeave {
875872
DLF.Watch.Called DLF.Event.MeLeave : $1-
876873
DLF.AlreadyHalted $1-
874+
DLF.SearchBot.MeLeave $chan
877875
; Remove all users from oNotice window
878876
DLF.oNotice.DelNickAllChans
879877
; Colour find responses now that I am no longer in channel
@@ -931,6 +929,7 @@ alias -l DLF.Event.JustConnected {
931929
alias -l DLF.Event.Disconnect {
932930
DLF.Watch.Called DLF.Event.Disconnect : $1-
933931
DLF.AlreadyHalted $1-
932+
DLF.SearchBot.Disconnect
934933
DLF.oNotice.DelNickAllChans
935934
; Colour find responses now that I am no longer in channel
936935
@@ -2395,25 +2394,63 @@ alias -l DLF.DccChat.Open {
23952394
}
23962395

23972396
; ========== SearchBot Triggers ==========
2397+
alias -l DLF.SearchBot.MeJoin {
2398+
; Record channel delay if channel has mode +d
2399+
DLF.Watch.Called DLF.SearchBot.MeJoin $1 : $2-
2400+
var %i $numtok($2-,$space)
2401+
while (%i) {
2402+
if (+*d* iswm $gettok($2-,%i,$asc($space))) {
2403+
var %delay $gettok($2-,-1,$asc($space))
2404+
DLF.Watch.Log Searchbot: Recording that $1 has talk delay: %delay
2405+
if (%delay == $null) %delay = 30
2406+
hadd -mzu $+ %delay DLF.sbchandelay $+($network,$1) %delay
2407+
break
2408+
}
2409+
dec %i
2410+
}
2411+
}
2412+
2413+
alias -l DLF.SearchBot.MeLeave {
2414+
DLF.Watch.Called DLF.SearchBot.MeLeave $1 : $2-
2415+
var %nc $+($network,$1)
2416+
.timer $+ DLF.sbgetriggers. $+ %nc off
2417+
if ($hget(DLF.sbchandelay) !== $null) hdel DLF.sbchandelay %nc
2418+
}
2419+
2420+
alias -l DLF.SearchBot.Disconnect {
2421+
DLF.Watch.Called DLF.SearchBot.Disconnect $1 : $2-
2422+
var %i $chan(0)
2423+
while (%i) {
2424+
DLF.SearchBot.MeLeave $chan(%i)
2425+
dec %i
2426+
}
2427+
}
2428+
23982429
; hash table index network|channel|nick|trigger
23992430
alias -l DLF.SearchBot.GetTriggers {
24002431
DLF.Watch.Called DLF.SearchBot.GetTriggers $1 : $2-
2401-
var %nc = $+($network,$1)
2432+
var %nc $+($network,$1)
24022433
; If current trigger request is active, don't send another one
2403-
var %req = $hget(DLF.sbcurrentreqs,%nc)
2434+
var %req $hget(DLF.sbcurrentreqs,%nc)
24042435
if (%req != $null) return
24052436
; If we have previously requested but not had any responses then try again.
2406-
%req = $hget(DLF.sbrequests,$+($network,$1))
2437+
%req = $hget(DLF.sbrequests,%nc)
24072438
var %bots = $hfind(DLF.searchbots,$+($network,|,$1,|*),0,w).item
24082439
if ((%req != $null) && (%bots > 0) && ($2 == $null)) return
24092440
; If trigger is a search and it is not in the searchbots table then re-request triggers
2410-
var %nick = $DLF.SearchBot.NickFromTrigger($2,$1)
2441+
if (@* iswm $2) var %nick $DLF.SearchBot.NickFromTrigger($2,$1)
2442+
else var %nick $DLF.SearchBot.TriggerFromNick($2,$1)
24112443
if (%nick != $null) return
2412-
DLF.Watch.Log SearchBot: Requesting Triggers
2413-
var %ttl $DLF.SearchBot.TTL
2414-
hadd -mzu $+ %ttl DLF.sbrequests $+($network,$1) %ttl
2415-
hadd -mzu60 DLF.sbcurrentreqs $+($network,$1) 60
2416-
.msg $1 @SearchBot-Trigger
2444+
; Check for channel mode +d and delay request until request will not be rejected
2445+
var %delay $hget(DLF.sbchandelay,%nc)
2446+
if (%delay == $null) %delay = 0
2447+
var %ttl $DLF.SearchBot.TTL + %delay
2448+
var %timeout 60 + %delay
2449+
hadd -mzu $+ %ttl DLF.sbrequests %nc %ttl
2450+
hadd -mzu $+ %timeout DLF.sbcurrentreqs %nc %timeout
2451+
DLF.Watch.Log SearchBot: Requesting Triggers for %nc in %delay seconds
2452+
if (%delay == 0) .msg $1 @SearchBot-Trigger
2453+
else .timer $+ DLF.sbgetriggers. $+ %nc 1 %delay .msg $1 @SearchBot-Trigger
24172454
}
24182455

24192456
; ctcp TRIGGER network chan trigger
@@ -6362,9 +6399,15 @@ alias DLF.Watch.Filter {
63626399
%text = : $+ $gettok(%text,2-,$asc(:))
63636400
}
63646401
var %user
6365-
if (($1 == <-) && (:* iswm %text)) {
6402+
if ($1 == <-) {
6403+
if (:* iswm %text) {
63666404
%user = $right($gettok(%text,1,$asc($space)),-1)
63676405
%text = $gettok(%text,2-,$asc($space))
6406+
}
6407+
else {
6408+
DLF.Watch.Log $1-
6409+
return
6410+
}
63686411
}
63696412
elseif ($1 == ->) {
63706413
%user = $gettok(%text,1,$asc($space))
@@ -6407,7 +6450,7 @@ alias -l DLF.Watch.Log {
64076450
elseif ($window($debug)) {
64086451
DLF.Win.CustomTrim $debug
64096452
var %c 3
6410-
if (%ticks == 0) %c = 10
6453+
if (%ticks == 0) %c = 6
64116454
if ($1 == <-) %c = 1
64126455
elseif ($1 == ->) %c = 12
64136456
elseif ($1 == Halted:) %c = 4

0 commit comments

Comments
 (0)