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 

Snotice shun
Goto page 1, 2  Next
 
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: 16

PostPosted: Thu Aug 04, 2022 9:40 pm    Post subject: Snotice shun Reply with quote

bind raw - *Shun added for* NOTICE snotice
proc snotice {from keyword arg} {
if {![string match -nocase "*shun added for:*" $arg]} { return }
set nick [lindex [lindex [split $arg :] 1] 0]
putserv "privmsg #shuned $arg"
}


bind pub o !shun pub:shun
proc pub:shun {nick host hand chan text} {
global botnick channels
if {[llength $text] < 1} { putserv "privmsg $channels $nick: Used !shun nick +tiempo razón"
return 0
}
set channels "#shuned"
set target [lindex $text 0]
set tiempo [lindex $text 1]
set reason [lrange $text 2 end]
if {($target != "")} {
putquick "shun $target $tiempo $reason"
} else {
if {($target == "")} {
putquick "shun $target $tiempo $reason"

return 0
}
return 0
}
}


<user1> !shun user2 +1h test

the code is fine but the SNOTICE message does not appear on the channel when the command !shun nick time reason is used

I would like it to stay like this

<user1> !shun user2 +1h test
<botnick> -NOTICE- *** Shun added for *@host.de on Fri Aug 5 00:33:30 2022 GMT (from botnick!bot@bot.tk to expire at Fri Aug 5 01:33:30 2022 GMT: test)

please help me thank you
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Thu Aug 04, 2022 10:33 pm    Post subject: Reply with quote

On which ircd version did you use this so i can test it to figure whats wrong with the code as i run several test ircds myself
Back to top
View user's profile Send private message
bwkzb
Voice


Joined: 12 Mar 2017
Posts: 16

PostPosted: Thu Aug 04, 2022 10:43 pm    Post subject: Reply with quote

I use it in unrealircd 5.2.4

thanks for answer Very Happy
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Fri Aug 05, 2022 12:03 am    Post subject: Reply with quote

tested this seems to work for me:

Code:

bind raw - notice shun-snotice

proc shun-snotice {from keyword arg} {
 if {![string match -nocase "*shun added*" $arg]} { return }
   set shun [lrange $arg 1 end]
   putserv "privmsg #shuned :$shun"
}


bind pub o !shun pub:shun

proc pub:shun {nick host hand chan text} {
global botnick
   if {[llength $text] < 1} { putserv "privmsg $channels $nick: Used !shun nick +tiempo razón"
  return 0
}
  set target [lindex $text 0]
  set tiempo [lindex $text 1]
  set reason [lrange $text 2 end]
 if {($target != "")} {
   putquick "shun $target $tiempo $reason"
} else {
 putquick "shun $target :$tiempo $reason"
  return 0
}
}



Last edited by simo on Fri Aug 05, 2022 5:08 am; edited 2 times in total
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 991
Location: France

PostPosted: Fri Aug 05, 2022 3:44 am    Post subject: Reply with quote

Really strange:
Code:
 if {($target != "")} {
   putquick "shun $target $tiempo $reason"
} else {
 if {($target == "")} {

 putquick "shun $target :$tiempo $reason"
}


Simplification:
Code:
 if {($target != "")} {
   putquick "shun $target $tiempo $reason"
} else {
   putquick "shun $target :$tiempo $reason"
}

When in the else ($target is empty), $tiempo and $reason are empty too (as $target is the first element of $text), and the shun will alway fail.
BTW, $target can never be empty as the first check is to ensure that $text has at least 1 element.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Fri Aug 05, 2022 5:01 am    Post subject: Reply with quote

Thanks for pointing that out CrazyCat
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Fri Aug 05, 2022 8:34 pm    Post subject: Reply with quote

slightly revised in the case of nicks with chars like {} in it and added protection for channel admins / ops and those with bot flag o and with pre filled reason and ban duration if not given

Code:


bind raw - notice shun-snotice

proc shun-snotice {from keyword arg} {
 if {![string match -nocase "*shun added*" $arg]} { return }
   set shun [lrange $arg 1 end]
   putserv "privmsg #shuned :$shun"
}


bind pub o !shun pub:shun

proc pub:shun {nick host hand chan text} {
  set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
  set text [split $text]
  set target [lindex $text 0]
  set tiempo [lindex $text 1]
  set reason [lrange $text 2 end]
  set items [split $text]
   if {[llength $items] < 1} { putnow "NOTICE $nick :Syntax\: !shun nick" ; return }

  if {$tiempo eq ""} { set tiempo "1h"  }
  if {$reason eq ""} { set reason "$tiempo shun for abuse/behaviour"  }


if {![onchan $target $chan]} {
                putnow "NOTICE $nick $target is not on $chan"
  }  else {
    if {![isbotnick $target] && ![isbotnick $target] && ![isop $target $chan] && ![ishalfop $target $chan] && ![matchattr [nick2hand $target $chan] o|o $chan]} {
    putquick "shun $target $tiempo $reason"
     }
   }
}

 
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Sat Aug 06, 2022 12:37 am    Post subject: Reply with quote

anyway we can determine if $tiempo is in the syntax of 12h 1d 1m 1y

and $reason to be in alpha/numeric in my last posted code ?


because now when used like !shun nick some reason it wont work proper
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 785
Location: Tennessee, USA

PostPosted: Sat Aug 06, 2022 6:23 pm    Post subject: !shun nick duration reason Reply with quote

Code:

bind raw - notice shun-snotice

proc shun-snotice {from keyword arg} {
 if {![string match -nocase "*shun added*" $arg]} { return }
   set shun [lrange $arg 1 end]
   putserv "privmsg #shuned :$shun"
}


bind pub o !shun pub:shun

proc pub:shun {nick host hand chan text} {
  set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
  set text [split $text]
  if {![llength $text]} { putnow "NOTICE $nick :Syntax\: !shun nick" ; return 0 }

  set target [lindex $text 0]
  if {![onchan $target $chan]} { putnow "NOTICE $nick :$target is not on $chan" ; return 0 }

  if {[isbotnick $target] || [isop $target $chan] || [ishalfop $target $chan]} { return 0 }
  if {[matchattr [nick2hand $target $chan] o|o $chan]} { return 0 }

  set tiempo [lindex $text 1]
  set reason [join [lrange $text 2 end]]

  if {$tiempo ne "" && ![regexp -nocase {^[1-9][0-9]*[hdmy]$} $tiempo]} {
    set reason [string trim "$tiempo $reason"]
    set tiempo ""
  }

  if {$tiempo eq ""} { set tiempo "1h"  }
  if {$reason eq ""} { set reason "$tiempo shun for abuse/behaviour"  }

  putquick "shun $target $tiempo $reason"
  return 0
}


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Sat Aug 06, 2022 8:13 pm    Post subject: Reply with quote

thanks SpiKe^^ i tried your posted code with like:

Quote:
!shun Finn 10s


wich resulted in :

Quote:
*** Shun added for *@184.178.172.25 on Sun Aug 7 00:08:38 2022 GMT (from &Falcon!F@127.0.0.1 to expire at Sun Aug 7 01:08:38 2022 GMT: 10s)


so the reason wasnt filled in only the targetnick and duration but still the default duration of 1 hour was used while we filled 10 seconds in and the default reason wasnt used since it wasnt filled in not sure why
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 785
Location: Tennessee, USA

PostPosted: Sat Aug 06, 2022 8:42 pm    Post subject: Reply with quote

You didn't specify #s in your example....
Quote:
$tiempo is in the syntax of 12h 1d 1m 1y


Adjust the regexp to cover what you see as all the choices...
Code:
{^[1-9][0-9]*[hdmy]$}

_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Sat Aug 06, 2022 9:55 pm    Post subject: Reply with quote

oh thanks SpiKe^^ i overlooked that part after consulting help file for shun on the ircd i found the actual syntax that is used by the ircd and i inserted that in the below code thanks again SpiKe^^.

Final code is :

Code:


bind raw - notice shun-snotice

proc shun-snotice {from keyword arg} {
 if {![string match -nocase "*shun added*" $arg]} { return }
   set shun [lrange $arg 1 end]
   putserv "privmsg #shuned :$shun"
}


bind pub o !shun pub:shun

proc pub:shun {nick host hand chan text} {
  set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
  set text [split $text]
  if {![llength $text]} { putnow "NOTICE $nick :Syntax\: !shun nick" ; return 0 }

  set target [lindex $text 0]
  if {![onchan $target $chan]} { putnow "NOTICE $nick :$target is not on $chan" ; return 0 }

  if {[isbotnick $target] || [isop $target $chan] || [ishalfop $target $chan]} { return 0 }
  if {[matchattr [nick2hand $target $chan] o|o $chan]} { return 0 }

  set tiempo [lindex $text 1]
  set reason [join [lrange $text 2 end]]

  if {$tiempo ne "" && ![regexp -nocase {^[1-9][0-9]*[dhms]$} $tiempo]} {
    set reason [string trim "$tiempo $reason"]
    set tiempo ""
  }

  if {$tiempo eq ""} { set tiempo "1h"  }
  if {$reason eq ""} { set reason "$tiempo shun for abuse/behaviour"  }

  putquick "shun $target $tiempo $reason"
  return 0
}
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Sat Aug 06, 2022 10:03 pm    Post subject: Reply with quote

oh 1 last thing since shun command also provides option to set a permanent shun but that is set with durarion of just 0 without any additional param anyway we can incorporate that ?
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 785
Location: Tennessee, USA

PostPosted: Sun Aug 07, 2022 12:42 pm    Post subject: Reply with quote

Replace this line in the code...
Code:
  if {$tiempo ne "" && ![regexp -nocase {^[1-9][0-9]*[dhms]$} $tiempo]} {


With something more like this...
Code:
  if {$tiempo ne "" && ![regexp -nocase {^[1-9][0-9]*[dhms]$} $tiempo] && $tiempo != 0} {

_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 902

PostPosted: Sun Aug 07, 2022 2:24 pm    Post subject: Reply with quote

thanks SpiKe^^ that seems to do it

final code for those that need it :

Code:

bind raw - notice shun-snotice

proc shun-snotice {from keyword arg} {
 if {![string match -nocase "*shun added*" $arg]} { return }
   set shun [lrange $arg 1 end]
   putserv "privmsg #shuned :$shun"
}


bind pub o !shun pub:shun

proc pub:shun {nick host hand chan text} {
  set text [regsub -all -- {\s{2,}} [string trim [stripcodes * $text]] { }]
  set text [split $text]
  if {![llength $text]} { putnow "NOTICE $nick :Syntax\: !shun nick" ; return 0 }

  set target [lindex $text 0]
  if {![onchan $target $chan]} { putnow "NOTICE $nick :$target is not on $chan" ; return 0 }

  if {[isbotnick $target] || [isop $target $chan] || [ishalfop $target $chan]} { return 0 }
  if {[matchattr [nick2hand $target $chan] o|o $chan]} { return 0 }

  set tiempo [lindex $text 1]
  set reason [join [lrange $text 2 end]]

  if {$tiempo ne "" && ![regexp -nocase {^[1-9][0-9]*[dhms]$} $tiempo] && $tiempo != 0} {
    set reason [string trim "$tiempo $reason"]
    set tiempo ""
  }

  if {$tiempo eq ""} { set tiempo "1h"  }
  if {$reason eq ""} { set reason "$tiempo shun for abuse/behaviour"  }

  putquick "shun $target $tiempo $reason"
  return 0
}
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
Goto page 1, 2  Next
Page 1 of 2

 
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