| View previous topic :: View next topic |
| Author |
Message |
ThE-UnNaMeD Voice
Joined: 25 Nov 2007 Posts: 9 Location: Local Disc (C:)
|
Posted: Sat Feb 16, 2008 5:00 am Post subject: Auto -mi |
|
|
If someone sets +mi automatically does -mi after 2min.
i think it's easy, but i don't know how to make it..  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Feb 16, 2008 6:51 am Post subject: |
|
|
| Code: | bind mode - {% +m} rem:mi
bind mode - {% +i} rem:mi
proc rem:mi {nick uhost hand chan mc targ} {
global remmi
set remmi($mc:$chan) 1
if {![info exists remmi(+m:$chan)] || ![info exists remmi(+i:$chan)]} {
return 0
}
if {$remmi(+m:$chan) && $remmi(+i:$chan)} {
timer 2 [list rem:modes $chan]
}
}
proc rem:modes chan {
global remmi
pushmode $chan -m
pushmode $chan -i
set remmi(+m:$chan) [set remmi(+i:$chan) 0]
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
noobman Voice
Joined: 23 Nov 2007 Posts: 29
|
Posted: Sat Feb 16, 2008 7:38 am Post subject: and to set it in 30 seconds ? |
|
|
| Code: | | timer 2 [list rem:modes $chan] |
it means after 2 min, remove +mi , and to can change it to 30 seconds ?
is it | Code: | | utimer 30 [list rem:modes $chan] | ??
thanks. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
noobman Voice
Joined: 23 Nov 2007 Posts: 29
|
Posted: Sat Feb 16, 2008 9:01 am Post subject: problem |
|
|
ok i tried to test it and add for +r mode too.
| Code: | bind mode - {% +m} rem:mi
bind mode - {% +i} rem:mi
bind mode - {% +r} rem:mi
proc rem:mi {nick uhost hand chan mc targ} {
global remmi
set remmi($mc:$chan) 1
if {![info exists remmi(+m:$chan)] || ![info exists remmi(+r:$chan)] || ![info exists remmi(+i:$chan)]} {
return 0
}
if {$remmi(+m:$chan) && {$remmi(+i:$chan) && $remmi(+r:$chan)} {
utimer 30 [list rem:modes $chan]
}
}
proc rem:modes chan {
global remmi
pushmode $chan -m
pushmode $chan -i
pushmode $chan -r
set remmi(+m:$chan) [set remmi(+i:$chan) [set remmi(+r:$chan) 0] |
and i get the following error :
missing close-brace
while executing
"proc rem:mi {nick uhost hand chan mc targ} {
global remmi
set remmi($mc:$chan) 1
if {![info exists remmi(+m:$chan)] ||  |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Feb 16, 2008 2:00 pm Post subject: |
|
|
| Code: | bind mode - {% +m} rem:mi
bind mode - {% +i} rem:mi
bind mode - {% +r} rem:mi
proc rem:mi {nick uhost hand chan mc targ} {
global remmi
set remmi($mc:$chan) 1
if {![info exists remmi(+m:$chan)] || ![info exists remmi(+r:$chan)] || ![info exists remmi(+i:$chan)]} {
return 0
}
if {$remmi(+m:$chan) && $remmi(+i:$chan) && $remmi(+r:$chan)} {
utimer 30 [list rem:modes $chan]
}
}
proc rem:modes chan {
global remmi
pushmode $chan -m
pushmode $chan -i
pushmode $chan -r
set remmi(+m:$chan) [set remmi(+i:$chan) [set remmi(+r:$chan) 0]]
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Sun Feb 17, 2008 10:15 am Post subject: |
|
|
A simple and dynamic form of this script would be:
Use ".chanset #channel remove-modes mir" to make the bot remove +mir after <so many> seconds.
| Code: | setudef str remove-modes
bind MODE -|- "% +*" check:mode
proc check:mode {nickname hostname handle channel mode target} {
if {[set remmodes [channel get $channel "remove-modes"]] == ""} {
return 0
}
set mode [string trimleft $mode "+"]
if {[string match *$mode* $remmodes]} {
utimer 60 [list pushmode $channel -$mode]
}
}
|
edit: whatever.
Last edited by metroid on Sun Feb 17, 2008 7:43 pm; edited 4 times in total |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Feb 17, 2008 10:24 am Post subject: |
|
|
Tcl-commands.doc:
| Quote: | MODE (stackable)
bind mode <flags> <mask> <proc>
proc-name <nick> <user@host> <handle> <channel> <mode-change> <target>
Description: mode changes are broken down into their component
parts before being sent here, so the <mode-change> will always
be a single mode, such as "+m" or "-o". target will show the
argument of the mode change (for o/v/b/e/I) or "" if the set
mode does not take an argument. The bot's automatic response
to a mode change will happen AFTER all matching Tcl procs are
called. The mask will be matched against '#channel +/-modes'
and can contain wildcards. |
So, in your case metroid, $mode will never contain more than one mode. Also, the wildcards in [string match] can only be applied on the first operand and not the 2nd. Another problem with your code is that it's reapplying the mode which is not what's requested, and of course setting +$mode is not valid since mode already contains the '+' char. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Sun Feb 17, 2008 12:17 pm Post subject: |
|
|
Forgot about the + in $mode. So that's fixed.
And I'm fully aware that MODE only sends 1 mode through which is why I used pushmode.
| Quote: | pushmode <channel> <mode> [arg]
Description: sends out a channel mode change (ex: pushmode #lame +o
goober) through the bot's queuing system. All the mode changes will
be sent out at once (combined into one line as much as possible) after
the script finishes, or when 'flushmode' is called.
Returns: nothing
Module: irc
|
And in this case, it will wait long enough to set the other modes too.
Don't be too quick to say that my code is completely wrong when there was only a small mistake there. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Feb 17, 2008 2:21 pm Post subject: |
|
|
You still haven't corrected the main mistake:
| Code: | | if {[string match $remmodes *$mode*]} { |
As I already said before that wildcards are used on the 1st operand of [string match] and not on the 2nd. So what you meant here is
| Code: | | if {[string match *$mode* $remmodes]} { |
Then it would make some sense, however this does not care about whether the modes where set at the same time or separately.
I didn't say that your code is completely wrong metroid, learn to accept critic. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Feb 17, 2008 3:11 pm Post subject: |
|
|
Another advice, since reapply:mode only calls pushmode, with the exact same number of arguments, in the same order - why not simply call pusmode in the first place? _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
ThE-UnNaMeD Voice
Joined: 25 Nov 2007 Posts: 9 Location: Local Disc (C:)
|
Posted: Mon Feb 18, 2008 9:28 am Post subject: |
|
|
Tnx!!  |
|
| Back to top |
|
 |
bryanwny Voice
Joined: 09 Sep 2012 Posts: 24
|
Posted: Mon Oct 08, 2012 6:52 pm Post subject: |
|
|
I tried out metroids version of this script, because I liked the fact of being able to turn it on/off and changing the modes easily from DCC chat if needed.
Is there any way to make the bot actually check after the timer if the mode is still actually on, before removing it? Sometimes another OP will remove the +i, and the bot still sets -i later when it isn't necessary. |
|
| Back to top |
|
 |
bryanwny Voice
Joined: 09 Sep 2012 Posts: 24
|
Posted: Sat Jan 05, 2013 2:42 am Post subject: |
|
|
Haven't really had an issue with people leaving +M or +R on lately, so I kind of forgot about this, but I still haven't really been able to find (or modify) a script to do just what I'm looking for.
I run AllProtection which sets modes to stop floods for a minute, but if people keep rejoining and flooding numerous times, the ops set either +M or +R. The problem is (especially with +R) that it gets left on accidentally for hours at a time and the channel dwindles down to half the normal size.
This is what I'm looking for, and hopefully someone can help me out if they're feeling generous and/or bored.
1) Trigger the timer to start only when +M and/or +R were set. Not a timer that just runs every 30 minutes, because if +M/+R were set at the 25th minute, it's going to unlock the channel in 5 mins and not the 30 I was hoping for.
2) Make the bot check to see if someone else removed the +M/+R before that 30 minutes, so that it doesn't set -M/-R when it wasn't even set anymore.
After thinking about it, I guess I don't really care about it being dynamic since I would probably never change it anyways after it's initially set. |
|
| Back to top |
|
 |
|