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.

set mode on join

Help for those learning Tcl or writing their own scripts.
Post Reply
G
Gulio
Halfop
Posts: 74
Joined: Sun Nov 01, 2020 11:53 am

set mode on join

Post by Gulio »

i want to set samode both 2 channels +E when is match hostmask *.mibbit.com on join and to unset mode channels after 60 min
can someone help thx in advance

Code: Select all

Joins: mib_ufoo9l (59d2ec67@Test-B3B25F2D.mibbit.com)

Code: Select all

set chanban "#test1 #test2"
set checkdomain {"*.mibbit.com"}
set chanmode "E"
set timemode "60"

bind join - * banmibbit

proc banmibbit {nick host hand chan} {
	global chanban checkdomain chanmode timemode
	if {![chan gets $chanban] || [isbotnick $nick]} { return 0 }
	foreach checkdomain $chanban {
		if {[string match $checkdomain $chanban]} { return }
		foreach chan $chanban {
			putquick "samode $chanban +$chanmode"
		} else {
			utimer 60 [list $timemode]
			putquick "samode $chanban -$chanmode"

		}

	}
}
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

What is exactly the +E mode ?
And who did this script for you ? It does (when errors are corrected) exactly the invert of what you want.

Let me explain your script:

Code: Select all

set chanban "#test1 #test2"
set checkdomain {"*.mibbit.com"}
set chanmode "E"
set timemode "60"

bind join - * banmibbit

proc banmibbit {nick host hand chan} {
   global chanban checkdomain chanmode timemode
   if {![chan gets $chanban] || [isbotnick $nick]} { return 0 }
# [chan gets $chanban] is an error, so you alway exit from the proc
   foreach checkdomain $chanban {
      if {[string match $checkdomain $chanban]} { return }
# if domain is mibbit.com, you exit from the proc ???
      foreach chan $chanban {
# reuse of $chan is a bad idea. And $chanban is not a list
         putquick "samode $chanban +$chanmode"
# you send the command "samode #test1 #test2 +E" ???
      } else {
# foreach ... else ... ? WTF ?
         utimer 60 [list $timemode]
# what is doing your utimer ?
         putquick "samode $chanban -$chanmode"
# you send the command "samode #test1 #test2 -E" ???
      }
   }
}
And what happen if another mibbit user join the chan during the delay? the mode +E is sent, but the first timer (when corrected) will remove it
G
Gulio
Halfop
Posts: 74
Joined: Sun Nov 01, 2020 11:53 am

hi

Post by Gulio »

mode +E is my module who block users with this hostmask of mibbit to talk in channe'
G
Gulio
Halfop
Posts: 74
Joined: Sun Nov 01, 2020 11:53 am

hi

Post by Gulio »

and now how need to be ? now no errors but is not set mode on channels

Code: Select all


set chanban "#test1 #test2"
set checkdomain {"*.mibbit.com"}
set chanmode "E"
set timemode "60"

bind join - * banmibbit

proc banmibbit {nick host hand chan} {
	global chanban checkdomain chanmode timemode
	if {![isbotnick $nick]} { return 0 }
	foreach checkdomain $chanban {
		if {[string match $checkdomain $chanban]} {
			putquick "samode $chanban +$chanmode"
			utimer 60 [list $timemode]
			putquick "samode $chanban -$chanmode"
		}

	}
}

User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

It's worst than the previous...

Here is a small version, with explanations inline

Code: Select all

set chanban "#test1 #test2"
set checkdomain {"*.mibbit.com"}
set chanmode "E"
set timemode "60"

bind join - * banmibbit

proc banmibbit {nick uhost hand chan} {
	if {![string first [string tolower $chan] $::chanban] || [isbotnick $nick]} { return 0 }
# exit if the joined channel is not in $chanban or if the bot is joining
	foreach dom $::checkdomain {
# loop on each domain to check
		if {![string match -nocase $dom $uhost]} { continue }
# if user host doesn't match the domain, we continue (don't do the following)
		foreach vchan [split $::chanban] {
# loop on each chan in $chanban
			putquick "SAMODE $vchan +$::chanmode"
# do the SAMODE (just +E ?)
			utimer $::timemode [list [putquick "SAMODE $vchan -$::chanmode"]]
# after the timer, the remove of the +E
		}
	}
}
Note that this doesn't correct the trouble I specified: what happen if a mibbit user joins after 59 minutes ? The +E will be removed 1 min later, and 1h later, a try to do a -E will be done too.

Another point: why SAMODE ? only Services Admin can set the +E on a chan ?
G
Gulio
Halfop
Posts: 74
Joined: Sun Nov 01, 2020 11:53 am

Hi

Post by Gulio »

If the user join 1 min after bot unset mode -E to set again evry time when or to stay +E is match hostmask *.mibbit.com till is not enter again
yes samode is for ircops opers flags command
Last edited by Gulio on Thu Sep 09, 2021 1:57 pm, edited 2 times in total.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

CrazyCat: I think I might change this line of code...

Code: Select all

if {![string first [string tolower $chan] $::chanban] || [isbotnick $nick]} { return 0 }
to something more like...

Code: Select all

if {([string first [string tolower $chan] $::chanban] == -1) || [isbotnick $nick]} { return 0 }
[string first ..] returns -1 for "not found", not 0
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
G
Gulio
Halfop
Posts: 74
Joined: Sun Nov 01, 2020 11:53 am

hi

Post by Gulio »

Spike^^ yes u right ur fix now works thx, but is set and unset mode now on join

Code: Select all


[20:59:50] * Joins: pheleas_frog (59d2ec67@Test-AED0FB6F.mibbit.com) 
[20:59:51] * irc.Test.com sets mode: +E
[20:59:51] * irc.Test.com sets mode: -E
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

SpiKe^^ wrote:CrazyCat: I think I might change this line of code...
[string first ..] returns -1 for "not found", not 0
Yes, quick code, untested, it was more to show how it can be done and to explain how it works.

Thx SpiKe^^ :)
Gulio wrote:If the user join 1 min after bot unset mode -E to set again evry time when or to stay +E is match hostmask *.mibbit.com till is not enter again
yes samode is for ircops opers flags command
You don't answer my questions:
- what happen if the user join 1 minute before the unset ? actually, the initial unset will act. Let me show you:
<14:40:00> user1@abc.mibbit.com joined #dummy
<14:40:01> bot sets mode +E on #dummy
<15:39:00> user2@abc.mibbit.com joined #dummy
<15:39:01> (nothing, #dummy is already +E)
<15:40:01> bot sets mode -E on #dummy
<16:39:01> (nothing, #dummy is already -E)

And I know SAMODE is for services admin (not "ircops", some ircops), my question was to know if this mode can be set by a "simple" operator of the chan.

But as each time I try to help you, I say "never again", now I promise I stop.
G
Gulio
Halfop
Posts: 74
Joined: Sun Nov 01, 2020 11:53 am

hi

Post by Gulio »

CracyCat
Need to kill time when a user join before expire time of unset mode so can start from start to count time maybe
but is ok thx a lot from ur help
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Re: hi

Post by SpiKe^^ »

Gulio wrote:..., but is set and unset mode now on join

Gulio: Try replacing this line of code...

Code: Select all

utimer $::timemode [list [putquick "SAMODE $vchan -$::chanmode"]]
with something more like...

Code: Select all

utimer $::timemode [list putquick "SAMODE $vchan -$::chanmode"]
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Post Reply