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 

pub command for specific vhost

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Thu Jul 07, 2016 7:35 pm    Post subject: pub command for specific vhost Reply with quote

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
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Fri Jul 08, 2016 1:47 am    Post subject: Reply with quote

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

_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Fri Jul 08, 2016 12:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Thu Jul 14, 2016 3:28 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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