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.

Auto -mi

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
T
ThE-UnNaMeD
Voice
Posts: 9
Joined: Sun Nov 25, 2007 11:08 am
Location: Local Disc (C:)
Contact:

Auto -mi

Post by ThE-UnNaMeD »

If someone sets +mi automatically does -mi after 2min.
i think it's easy, but i don't know how to make it.. :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

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]
}
n
noobman
Voice
Posts: 29
Joined: Fri Nov 23, 2007 8:47 am

and to set it in 30 seconds ?

Post by noobman »

Code: Select all

timer 2 [list rem:modes $chan]
it means after 2 min, remove +mi , and to can change it to 30 seconds ?

is it

Code: Select all

utimer 30 [list rem:modes $chan]
??

thanks.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Yes, that's correct.
n
noobman
Voice
Posts: 29
Joined: Fri Nov 23, 2007 8:47 am

problem

Post by noobman »

ok i tried to test it and add for +r mode too.

Code: Select all

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)] || ![info exists remmi(+r:$c..."
(file "scripts/quitamodos.tcl" line 5)
invoked from within


Please what must i do to solve it ? Thanks
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

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]]
}
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

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: Select all

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.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Tcl-commands.doc:
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.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

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.
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.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You still haven't corrected the main mistake:

Code: Select all

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: Select all

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.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
T
ThE-UnNaMeD
Voice
Posts: 9
Joined: Sun Nov 25, 2007 11:08 am
Location: Local Disc (C:)
Contact:

Post by ThE-UnNaMeD »

Sir_Fz wrote:code
Tnx!! :)
b
bryanwny
Voice
Posts: 24
Joined: Sun Sep 09, 2012 10:35 pm

Post by bryanwny »

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.
b
bryanwny
Voice
Posts: 24
Joined: Sun Sep 09, 2012 10:35 pm

Post by bryanwny »

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.
Post Reply