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 

sajoin with an exception

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Fri Dec 25, 2009 10:13 am    Post subject: sajoin with an exception Reply with quote

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:
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"

}

_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
BLaCkShaDoW
Op


Joined: 11 Jan 2009
Posts: 115
Location: Romania

PostPosted: Fri Dec 25, 2009 2:15 pm    Post subject: Reply with quote

Code:
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 Wink
_________________
BLaCkShaDoW Production @ WwW.TclScripts.Net


Last edited by BLaCkShaDoW on Sat Dec 26, 2009 3:04 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Fri Dec 25, 2009 5:10 pm    Post subject: Reply with quote

Works a treat as ever thanks BLaCkShaDoW
_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
BLaCkShaDoW
Op


Joined: 11 Jan 2009
Posts: 115
Location: Romania

PostPosted: Sat Dec 26, 2009 4:36 am    Post subject: Reply with quote

Your Welcome Smile
_________________
BLaCkShaDoW Production @ WwW.TclScripts.Net
Back to top
View user's profile Send private message Send e-mail Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Dec 26, 2009 12:26 pm    Post subject: Reply with quote

Code:
  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:
set chan [lindex [split $arg] 0]

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Sat Dec 26, 2009 2:40 pm    Post subject: Reply with quote

Code:
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
_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
BLaCkShaDoW
Op


Joined: 11 Jan 2009
Posts: 115
Location: Romania

PostPosted: Sat Dec 26, 2009 3:02 pm    Post subject: Reply with quote

Code:
#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 Smile
_________________
BLaCkShaDoW Production @ WwW.TclScripts.Net
Back to top
View user's profile Send private message Send e-mail Visit poster's website
BLaCkShaDoW
Op


Joined: 11 Jan 2009
Posts: 115
Location: Romania

PostPosted: Sat Dec 26, 2009 3:05 pm    Post subject: Reply with quote

Thanks for the sugestion speechles.
_________________
BLaCkShaDoW Production @ WwW.TclScripts.Net
Back to top
View user's profile Send private message Send e-mail Visit poster's website
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Sat Dec 26, 2009 3:19 pm    Post subject: Reply with quote

Cool Cheers BLaCkShaDoW
_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Dec 26, 2009 3:51 pm    Post subject: Reply with quote

Code:
set reason [lrange [split $arg] 0 end]

.... You forgot the join...
Code:
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:
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.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Thu Dec 31, 2009 7:44 am    Post subject: Reply with quote

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
_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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