| View previous topic :: View next topic |
| Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Thu Jul 07, 2016 7:35 pm Post subject: pub command for specific vhost |
|
|
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: |
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"
}
|
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Jul 08, 2016 1:47 am Post subject: |
|
|
To achieve what you asked for replace:
| Code: |
if {![isop $nick $chan]} return
|
with:
| Code: |
if {![string match -nocase "channel.bot" [lindex [split $uhost @] 1]]} return
|
You also need to replace:
| Code: |
if {[scan $text {%s%s} user reason] != 2} {
puthelp "NOTICE $nick :usage: !kl <nick> <reason>"
return
}
|
with:
| Code: |
if {[llength $text] != 2} {
puthelp "NOTICE $nick :usage: !kl <nick> <reason>"
} else {
set reason [lassign $text user]
}
|
and:
| Code: |
if {[scan $text {%s%s%s} user duration reason] != 3} {
puthelp "NOTICE $nick :usage: !sh nick!user@host duration :reason"
return
}
|
with:
| Code: |
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: |
% 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: |
% 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. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Fri Jul 08, 2016 12:54 pm Post subject: |
|
|
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: | 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"
} |
|
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Thu Jul 14, 2016 3:28 am Post subject: |
|
|
| 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: |
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: |
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. |
|
| Back to top |
|
 |
|