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.

sajoin with an exception

Help for those learning Tcl or writing their own scripts.
Post Reply
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

sajoin with an exception

Post by blake »

Im using the following code to allow users of my bot with flags +ho to use a command to forcejoin them selves into channels i want it to disallow them to forcejoin themselves into some channels unless the user also has flag +A

channels to not allow +ho users to forcejoin are #CWStats #Services #Opers #ChattersWorld-Opers

+A flag users need to be exempt from this

Code: Select all

bind msg ho|ho forcejoin cmd:forcejoin
proc cmd:forcejoin {nick uhost hand args} {
  set args [join $args]
  set chan [lrange $args 0 end]
  putserv "SAJOIN $nick :$chan"
  puthelp "NOTICE #ChattersWorld-Opers $nick forcedjoined into $chan"

}
User avatar
BLaCkShaDoW
Op
Posts: 121
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

Post by BLaCkShaDoW »

Code: Select all

set channels {
"#CWStats"
"#Services"
"#Opers"
"#ChattersWorld-Opers"
}




bind msg ho|ho forcejoin cmd:forcejoin 
proc cmd:forcejoin {nick uhost hand arg} {
global channels 
  set chan [lindex [split $arg] 0]
foreach c $channels {
if {!([matchattr $hand A|A $chan]) && [string match -nocase $c $chan]} {
return 0
}
}
  putserv "SAJOIN $nick :$chan" 
  puthelp "NOTICE #ChattersWorld-Opers :$nick forcedjoined into $chan" 

} 
Done try it ;)
Last edited by BLaCkShaDoW on Sat Dec 26, 2009 3:04 pm, edited 1 time in total.
BLaCkShaDoW Production @ WwW.TclScripts.Net
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

Works a treat as ever thanks BLaCkShaDoW
User avatar
BLaCkShaDoW
Op
Posts: 121
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

Post by BLaCkShaDoW »

Your Welcome :)
BLaCkShaDoW Production @ WwW.TclScripts.Net
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

  set args [split $arg]
  set chan [lrange $args 0 end] 
That part is goofy and introduces braces. These two lines should be turned into the one below.

Code: Select all

set chan [lindex [split $arg] 0]
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

Code: Select all

bind msg -|- report cmd:report
proc cmd:report {nick uhost hand arg} {
  set reason [lrange [split $arg] 0 ]
  putserv "NOTICE #Ops Report made by $nick $reason"
  puthelp "NOTICE $nick Your report has been recieved"
}
Need adding to this also what i need it to do is when someone uses the proc once it wont allow them to use it again untill 2 minues has passed if they try within the 2 minutes it
should notice them a message such as please wait 2 minutes before sending another report
User avatar
BLaCkShaDoW
Op
Posts: 121
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

Post by BLaCkShaDoW »

Code: Select all

#Here you set the time (in seconds)

set report(time) "120"

bind msg -|- report cmd:report 
proc cmd:report {nick uhost hand arg} {
global count report
set reason [lrange [split $arg] 0 end]
if {![info exists count(report:$uhost)]} { 
set count(report:$uhost) 0 
}
if {$count(report:$uhost) >= 1} {
puthelp "NOTICE $nick :Please wait for $report(time) seconds before sending another report."
return 0
}
incr count(report:$uhost)
utimer $report(time) [list unset count(report:$uhost)]
  putserv "NOTICE #badchans :Report made by $nick $reason" 
  puthelp "NOTICE $nick :Your report has been recieved" 
}
Done try it :)
BLaCkShaDoW Production @ WwW.TclScripts.Net
User avatar
BLaCkShaDoW
Op
Posts: 121
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

Post by BLaCkShaDoW »

Thanks for the sugestion speechles.
BLaCkShaDoW Production @ WwW.TclScripts.Net
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

Cool Cheers BLaCkShaDoW
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

set reason [lrange [split $arg] 0 end] 
.... You forgot the join...

Code: Select all

set reason [join [lrange [split $arg] 0 end]] 
blackshadow wrote:Thanks for the sugestion speechles.
Suggestion? It wasn't that at all. It was fixing the part which wasn't written correctly. The same as your code example shown above. This isn't a suggestion, this is a clear error within your script. You might say, meh, added braces when the reason contains spaces is a feature. Feature this isn't, it's clearly flawed understanding on lists vs strings. Blackshadow, all your scripts need to be checked for this problem you aren't watching closely enough these lessons and in your posts your teaching people horrible habits that are flawed...
blake wrote:Need adding to this also what i need it to do is when someone uses the proc once it wont allow them to use it again untill 2 minues has passed if they try within the 2 minutes it
should notice them a message such as please wait 2 minutes before sending another report
Use this simple script below which includes user's "throttle" procedure which is posted here.

Code: Select all

variable reportTime 120

bind msg -|- report cmd:report
proc cmd:report {nick uhost hand arg} {
  if {![throttled "$nick!$uhost" $::reportTime]} {
    set reason [join [lrange [split $arg] 0 end]]
    putserv "NOTICE #Ops :Report made: <$nick ($uhost)> $reason"
    puthelp "NOTICE $nick :Your report has been recieved"
  } else {
    puthelp "NOTICE $nick :Slow your roll.... You've been throttled!"
  }
} 

proc throttled {id seconds} {
   global throttle
   if {[info exists throttle($id)]&&$throttle($id)>[clock sec]} {
      set id 1
   } {
      set throttle($id) [expr {[clock sec]+$seconds}]
      set id 0
   }
}
# delete expired entries every 10 minutes
bind time - ?0* throttledCleanup
proc throttledCleanup args {
   global throttle
   set now [clock sec]
   foreach {id time} [array get throttle] {
      if {$time<=$now} {unset throttle($id)}
   }
}
This does exactly what you want. Tracking is done by "nick!ident@host" and each can only use this command once every 2 minutes.
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

Is it possible to add this what im looking for it to do now is still notice the report to #ops as it does but if it detects room names such as #trivia #blackjack #uno #hangman #DealOrNoDeal #Casino_Slots in the report it will notice channel #OtherStaff instead of #Ops all other reports will still need to goto #Ops
Post Reply