egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

doubt of code

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
bwkzb
Voice


Joined: 12 Mar 2017
Posts: 13

PostPosted: Tue Apr 09, 2019 12:32 am    Post subject: doubt of code Reply with quote

Code:

set spy(home) "#canal1"
set spy(chan) "#canal2"
set words { *banned* }

bind KICK   -|- "$spy(chan) *"   spychan:kick
proc spychan:kick { nickname hostname handle channel target reason } {
   global spy
   if {[string equal -nocase $channel $spy(chan)]} {
   putserv "PRIVMSG $spy(home) :$channel * $target was kicked from
$spy(chan) by $nickname $reason"
}
} else {
if {[string match "*" [string tolower $reason]]} {
     set results 0
     foreach x $::words {
     if {[string match -nocase *$x* $reason]} {
     incr results
     }
     }
     if {$results > 0} { putquick "SAJOIN $target #expulsed" }
}

how it could be transformed or added to this code that reads the kicks of users and bots with a certain reason.
For example, read the reason of the kick ("banned") and read that reason and send them back with a SAJOIN to a channel #expulsed


Last edited by bwkzb on Tue Apr 09, 2019 5:21 pm; edited 2 times in total
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2839

PostPosted: Tue Apr 09, 2019 1:17 pm    Post subject: Reply with quote

Let me see if I understood your question right:
You'd like to inspect all kick-reasons for certain keywords; if found, the target should be SAJOIN'd to some channel #expulsed?

In that case, most of the bits are already there; just some cleanup and proper syntax needed:
  • Your brackets, {}, are misaligned causing your proc to end before the "} else {" section. This would most likely throw an error when you try to load the script.
  • Testing the kick-reason against "*" will always be true, which is pointless. Just send the PRIVMSG. Also, the PRIVMSG has a newline in it, which cannot be sent correctly.
  • Since you are only interrested in finding a match, not the total number of matches, there's no point in iterating through the list of patterns once a match has been found. Do the SAJOIN here and then break

Code:
set spy(home) "#canal1"
set spy(chan) "#canal2"
set words { *banned* }

bind KICK -|- "$spy(chan) *" spychan:kick

proc spychan:kick {nickname hostname handle channel target reason} {
  putserv "PRIVMSG $spy(home) :$channel * $target was kicked from $spy(chan) by $nickname $reason"
  foreach x $::words {
    if {[string match -nocase "*$x*" "$reason"]} {
      putquick "SAJOIN $target #expulsed"
      break
    }
  }
}

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
bwkzb
Voice


Joined: 12 Mar 2017
Posts: 13

PostPosted: Fri Apr 19, 2019 4:00 pm    Post subject: Reply with quote

Thank you very much for responding and sorry for the delay.

and the variable so that the code reads the badwords of the reasons for the kicks in a .txt file as it would be
Code:

set spy(home) "#canal1"
set spy(chan) "#canal2"
set words "scripts/bd/bdreason.txt"

bind KICK -|- "$spy(chan) *" spychan:kick

proc spychan:kick {nickname hostname handle channel target reason} {
 global spy
 putserv "PRIVMSG $spy(home) :$channel * $target was kicked from $spy(chan) by $nickname $reason"
  foreach bdreason $::words {
    if {[string match -nocase "*$bdreason*" "$reason"]} {
      putquick "SAJOIN $target #expulsed"
      break
    }
  }
}
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2839

PostPosted: Mon Apr 22, 2019 4:28 pm    Post subject: Reply with quote

Well, there are a few ways we can go here...

  • Read the textfile to memory on startup
  • Read the textfile everytime the kick-binding triggers
  • A mix of the two... (advanced stuff)

In the first two cases, the code is pretty much the same; just a matter when to call it:
Code:
set fd [open "scripts/bd/bdreason.txt" "r"]
set ::words [split [read $fd] "\n"]
close $fd

This would add each line in bdreason.txt as a separate item in the _::words_ variable. This code could either be included inside the spychan:kick proc, or at the start of the script (in place of the current set words "scripts...").
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber