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.

Autosecret.tcl

Old posts that have not been replied to for several years.
M
Mikey
Voice
Posts: 13
Joined: Sun Apr 25, 2004 1:31 am
Location: Florida, USA

Autosecret.tcl

Post by Mikey »

Hello all. I am a bot owner and an IRCop on a network that is requesting that all bots not "just make a channel open/visiable". Via a compromise with the higher echlon opers it as been agreed that if a bot CAN (will) be able to set the channel mode +s when it is the only one in the channel that this would be an acceptable alternative to it parting and rejoining.

I am posting this in hopes that someone can draft an autosecret.tcl that will:

1: Be loaded as any normal tcl script
2: When (bot) is alone a channel set the channel +s
3: On a join, will change the channel mode -s
4: Configurable, if possible, to be set at how many chatters will be required to be in channel before it toggles. If this is not possible, then +s at 1 (the bot itself) while >2 will trigger -s

Many thanks in advance on any help that might be afforded on obtaining such a script.


Mikey
IRCop Serenity-irc.net
Bot owner
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

#just add to a file and load it as any other tcl script
#set this to the number of chatters before toggle
set togglechatters 2

bind part - * check:numbers:part
bind sign - * check:numbers:part

proc check:numbers {nick host hand chan arg} {
	resetchan $chan
	if {[llength [chanlist $chan]] == 1} {
		pushmode $chan "+s"
	}
}

bind join - * check:numbers:join

proc check:numbers:join {nick host hand chan arg} {
	resetchan $chan
	if {[llength [chanlist $chan]] >= $::togglechatters && [string match "s" [lindex [split [getchanmode $chan]] 0]]} {
		pushmode $chan "-s"
	}
}
^^untested :mrgreen:
Elen sila lúmenn' omentielvo
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

if {[llength [chanlist $chan]] >= $::togglechatters && [string match "*s*" [lindex [split [getchanmode $chan]] 0]]} {
Once the game is over, the king and the pawn go back in the same box.
M
Mikey
Voice
Posts: 13
Joined: Sun Apr 25, 2004 1:31 am
Location: Florida, USA

Post by Mikey »

Thanks for such a fast reply; however, as scripted is not seeming to work. In hopes of troubleshooting, let me outline what I have going on here.

My bot is running on the latest versions of Eggdrop and Stormbot. Listed below is the kind of server it is being run on and snippits from my config:

"Anvil.NJ.US.Serenity-IRC.Net Serene5.27 aAcfgiIjknNoOrRstxy bceHiklmnorRstv
NOQUIT TOKEN WATCH=128 SAFELIST NETWORK=Serenity-IRC CHANMODES=beH,k,l,imnstR MODES=6 MAXCHANNELS=10 NICKLEN=30 MAXBANS=60 EXCEPTS TOPICLEN=307 CHANNELLEN=32 CHARSET=ascii STD=i-d are available on this server"

# What is your network?
# 0 = EFnet (non +e/+I Hybrid)
# 1 = IRCnet
# 2 = Undernet
# 3 = DALnet
# 4 = +e/+I Hybrid
# 5 = Others
set net-type 0

(Really unsure of what exactly this setting should be. All else seems to work fine as set tho)

source scripts/alltools.tcl
source scripts/action.fix.tcl
source scripts/autosecret.tcl
source scripts/stormbot-beta.tcl


Again, many thanks,

Mikey
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

oups... :oops:

Code: Select all

proc check:numbers {nick host hand chan arg} {
should be

Code: Select all

proc check:numbers:part {nick host hand chan arg} {
Elen sila lúmenn' omentielvo
M
Mikey
Voice
Posts: 13
Joined: Sun Apr 25, 2004 1:31 am
Location: Florida, USA

Post by Mikey »

Thanks much to the both of you for taking the time in looking at this...

I must first begin by apologizing for my "I is not working" w/o any kind of explanation on what exactly is not working. :) I get that sometimes and feel it is like trying to find a needle in the haystack...

Having said that....

What seems to be happening, on my system, is that is not seeming to be reading any of the requested information the script is looking for to force the toggle/triggers.

This is what I have discovered:

1: A channel set -s, myself in it
2: (bot) /join # (should see itself only (??) and set +s ; it is not
3: me /part the # and the bot should see itself as alone and set +s ; it is not
4: # set to -s, make the bot cycle and upon completion DOES set +s but, will not remove when I do part and rejoin

Not sure if anyone else would take a stab at this script and let me know the outcome? If positive then I *KNOW* it is a confg trublem I have locally and can go from there...

Respectfully,

Mikey
M
Mikey
Voice
Posts: 13
Joined: Sun Apr 25, 2004 1:31 am
Location: Florida, USA

Post by Mikey »

I must add that the toggles are set as originally drafted... 2

Mikey
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

I hoped the resetchan command would do the trick..
obviously it didn't ;)
try this with utimers

Code: Select all

#just add to a file and load it as any other tcl script 
#set this to the number of chatters before toggle 
set togglechatters 2 

bind part - * check:numbers:part 
bind sign - * check:numbers:part 

proc check:numbers:part {nick host hand chan arg} { 
   resetchan $chan 
   utimer 2 [list dothecheck $chan 1] 
} 

proc dothecheck {a b} {
	switch $b {
	  {1} {
		if {[llength [chanlist $a]] == 1} { 
			pushmode $a "+s" 
		}
	  {2} {
		if {[llength [chanlist $a]] >= $::togglechatters && [string match "s" [lindex [split [getchanmode $a]] 0]]} { 
		      pushmode $a "-s" 
	        }
	}
}

bind join - * check:numbers:join 

proc check:numbers:join {nick host hand chan arg} { 
   resetchan $chan 
   utimer 2 [list dothecheck $chan 2] 
}
Elen sila lúmenn' omentielvo
M
Mikey
Voice
Posts: 13
Joined: Sun Apr 25, 2004 1:31 am
Location: Florida, USA

Post by Mikey »

I wish I could have corrected this myself but, I know didly about tcl coding.

Seems there is a "missing close brace"

[00:10] Tcl error in file 'bones.conf':
[00:10] missing close-brace
while executing
"proc dothecheck {a b} {
switch $b {
{1} {
if {[llength [chanlist $a]] == 1} {
pushmode $a "+s"
}
{2} {
..."
(file "scripts/autosecret.tcl" line 13)
invoked from within
"source scripts/autosecret.tcl"
(file "bones.conf" line 1327)
[00:10] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)


Respectfully,

Mikey
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

*sigh

one tip for the future.. do NOT try to do ANYTHING without a cup of coffee first :-?

Code: Select all

proc dothecheck {a b} { 
   switch $b { 
     {1} { 
      if {[llength [chanlist $a]] == 1} { 
         pushmode $a "+s" 
      }
     }
     {2} { 
      if {[llength [chanlist $a]] >= $::togglechatters && [string match "s" [lindex [split [getchanmode $a]] 0]]} { 
            pushmode $a "-s" 
           } 
      }
   } 
}
Elen sila lúmenn' omentielvo
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

/me hands Papillon a cup of coffee :)

Again, you have forgot the * in "s" :) It should be "*s*" to match it and there is no need for "[lindex [split [getchanmode $a]] 0]", just [getchanmode $a] :P
Once the game is over, the king and the pawn go back in the same box.
M
Mikey
Voice
Posts: 13
Joined: Sun Apr 25, 2004 1:31 am
Location: Florida, USA

Post by Mikey »

Ok, we are showing signs of life here. Not completely off life support but, getting there. :)

1: It is setting +s as needed
2: It seems to be having some trumblems in removing it tho. (This was tested with '...string match "s" ...' and, and with Caeser's '...string match "*s*" ...')

Respectfully,

Mikey
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Try this (not tested):

Code: Select all

set s_threshold 1
bind join - * do_the_s_check
bind part - * do_the_s_check
bind sign - * do_the_s_check
bind splt - * do_the_s_check

proc do_the_s_check {nick uhost hand chan args} {
	if {[isbotnick $nick]} {
		utimer 5 [list do_the_s_check . . . $chan]
	} elseif {[validchan $chan]&&[botisop $chan]} {
		if {[llength [chanlist $chan]]>$::s_threshold} {
			if {[string match *s* [lindex [getchanmode $chan] 0]]]} {
				pushmode $chan -s
			}
		} elseif {![string match *s* [lindex [getchanmode $chan] 0]]]} {
			pushmode $chan +s
		}
	}
}
Have you ever read "The Manual"?
M
Mikey
Voice
Posts: 13
Joined: Sun Apr 25, 2004 1:31 am
Location: Florida, USA

Post by Mikey »

if {[llength [chanlist $a]] >= $::togglechatters && [string match "*s*" [getchanmode $a]]} {

Is not working... :(

Not sure but, we arent reading something the script is needing to know....


Mikey
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

caesar wrote:there is no need for "[lindex [split [getchanmode $a]] 0]", just [getchanmode $a] :P
Wrong. There could be a key containing the letter "s".
Have you ever read "The Manual"?
Locked