This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

pub command for specific vhost

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

pub command for specific vhost

Post by simo »

greetz i was wondering how to this small tcl could be changed to have it only trigger if certain vhost ( channel.bot ) uses it in instead of (if {![isop $nick $chan]} return ) with pubic cmd and as well as in pm msg of the eggdrop

Code: Select all

bind pub * !kl oper:kill 
proc oper:kill {nick uhost hand chan text} {
   if {![isop $nick $chan]} return
   if {[scan $text {%s%s} user  reason] != 2} {
      puthelp "NOTICE $nick :usage: !kl <nick>  <reason>"
      return
   }
if {[isbotnick $user]} {
# do whatever you wish
return
} 
   if {[isop $user $chan]} {
      puthelp "NOTICE $nick :$user Is Also Helper, You Cannot Use This Command On Them"
      return
   }
   putserv "KILL $user $reason"
}



bind pub * !sh oper:shun
proc oper:shun {nick uhost hand chan text} {
   if {![isop $nick $chan]} return
   if {[scan $text {%s%s%s} user duration reason] != 3} {
      puthelp "NOTICE $nick :usage: !sh nick!user@host duration :reason"
      return
   }
if {[isbotnick $user]} {
# do whatever you wish
return
} 
   if {[isop $user $chan]} {
      puthelp "NOTICE $nick :$user Is Also Helper, You Cannot Use This Command On Them"
      return
   }
   putserv "SHUN $user $duration $reason"
}
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

To achieve what you asked for replace:

Code: Select all

if {![isop $nick $chan]} return 
with:

Code: Select all

if {![string match -nocase "channel.bot" [lindex [split $uhost @] 1]]} return
You also need to replace:

Code: Select all

if {[scan $text {%s%s} user reason] != 2} {
	puthelp "NOTICE $nick :usage: !kl <nick>  <reason>"
	return
}
with:

Code: Select all

if {[llength $text] != 2} {
	puthelp "NOTICE $nick :usage: !kl <nick> <reason>"
} else {
	set reason [lassign $text user]
}
and:

Code: Select all

if {[scan $text {%s%s%s} user duration reason] != 3} {
	puthelp "NOTICE $nick :usage: !sh nick!user@host duration :reason"
	return
}
with:

Code: Select all

if {[llength $text] != 3} {
	puthelp "NOTICE $nick :usage: !sh nick!user@host duration :reason"
} else {
	set reason [lassign $text user duration]
	if {![scan $duration {%d} d]} {
		# set a defaul duration cos what the user gave is not a valid number
		set duration "10"
	}
}
cos reason will be just one word, for example if you do !kl nick some reason here the actual reason set by the scan will actually be some, and not some reason here as expected.

With scan as is right now:

Code: Select all

% set text "nick some reason here"
nick some reason here
% scan $text {%s%s} user reason
2
% puts $user
nick
% puts $reason
some
and with the lassign trick:

Code: Select all

% set text "nick some reason here"
% set reason [lassign $text user]
some reason here
% puts $user
nick
% puts $reason
some reason here
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

seems to work only the reason doesnt seem to take more than the first parameter (used your version)

if i do :

!kll Higgins lets try this

it kills with reason lets and leaves out other param

also is there a way to add more hosts than 1

so far this is what i have:

Code: Select all

bind pub * !kill oper:kill
proc oper:kill {nick uhost hand chan text} {
  if {![string match -nocase "channel.bot" [lindex [split $uhost @] 1]]} return 
  if {[llength $text] != 2} {
   puthelp "NOTICE $nick :usage: !kill <nick> <reason>"
} else {
   set reason [lassign $text user]
} 
if {[isbotnick $user]} {
# do whatever you wish
return
}
   if {[isop $user $chan]} {
      puthelp "NOTICE $nick :$user Is Also Helper, You Cannot Use This Command On Them"
      return
   }
   putserv "KILL $user $reason"
}



bind pub * !shun oper:shun
proc oper:shun {nick uhost hand chan text} {
if {![string match -nocase "channel.bot" [lindex [split $uhost @] 1]]} return 
   if {[llength $text] != 3} {
   puthelp "NOTICE $nick :usage: !shun nick!user@host duration reason"
} else {
   set reason [lassign $text user duration]
   if {![scan $duration {%d} d]} {
      # set a defaul duration cos what the user gave is not a valid number
      set duration "10"
   }
} 
if {[isbotnick $user]} {
# do whatever you wish
return
}
   if {[isop $user $chan]} {
      puthelp "NOTICE $nick :$user Is Also Helper, You Cannot Use This Command On Them"
      return
   }
   putserv "SHUN $user $duration :$reason"
}
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

simo wrote:seems to work only the reason doesnt seem to take more than the first parameter
While that method does work, in some cases, the best method for your code would be to use lrange, and split it:

Code: Select all

set reason [join [lrange [split $text] 1 end]]
For the Shun command, you would want to either declare the duration in the command, or set a default duration (like you did). If you set it hardcoded, this would make the command; !shun nick!*identd@*.host.or.IP <reasons for shun here>
If you want to allow the duration to be in the command, you'd also have to change the reason to match the argument value.
!shun nick!*identd@*.host.or.IP <duration> <reasons for shun> - this would make it:

Code: Select all

set duration [lindex $text 1]
set reason [join [lrange [split $text] 2 end]]
I don't see how or where you declared $user - do you mean to use $nick ?
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Post Reply