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.

Join Module

Help for those learning Tcl or writing their own scripts.
Post Reply
G
Goga
Halfop
Posts: 83
Joined: Sat Sep 19, 2020 2:12 am

Join Module

Post by Goga »

that TCL name was Fzcomands.tcl
If you want me to post whole file, I will.
I only want to add !Join command in this TCL.
If you can help me out.
Thanks.
Last edited by Goga on Wed Jan 06, 2021 12:35 am, edited 3 times in total.
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

That's quite the same.

As I don't know your full script, here is the basic version

Code: Select all

bind pub n|n !join makejoin
proc makejoin {nick uhost handle chan text} {
   if {![check:auth $nick $hand]} {return 0}
   if {![matchattr $hand n|n $chan]} {
      puthelp "NOTICE $nick :$::fzcom(logo): You do not have access to use this command."
      return 0
   }
   if {[llength [split $text]]!=1} {
      puthelp "NOTICE $nick :$::fzcom(logo): the command is !join #newchannel"
      return 0
   }
   if {[string index $text 0]!="#"} {
      puthelp "NOTICE $nick :$::fzcom(logo): the channel name must begin with #"
      return 0
   }
   if {[validchan [string tolower $text]} {
      puthelp "NOTICE $nick :$::fzcom(logo): I'm already on $text"
      return 0
   }
   channel add [string tolower $text]
}
G
Goga
Halfop
Posts: 83
Joined: Sat Sep 19, 2020 2:12 am

Post by Goga »

For your information, that was fzcommands.tcl part in which I want to add !join command.
I added your given bind but it didn't work
Can you help me more?

Moderator edit: Next time post the link to the script if it's in the TCL Archive, don't clog the forum with it.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

   if {![matchattr $hand n|n $chan]} {
      puthelp "NOTICE $nick :$::fzcom(logo): You do not have access to use this command."
      return 0
   }
this part won't ever be triggered because the bind is already tied to n|n:

Code: Select all

bind pub n|n !join makejoin
Instead of:

Code: Select all

   if {[llength [split $text]]!=1} {
      puthelp "NOTICE $nick :$::fzcom(logo): the command is !join #newchannel"
      return 0
   }
   if {[string index $text 0]!="#"} {
      puthelp "NOTICE $nick :$::fzcom(logo): the channel name must begin with #"
      return 0
   }
I would go with:

Code: Select all

if {[scan $text {%s} c] != 1} {
	puthelp "NOTICE $nick :$::fzcom(logo): the command is !join #newchannel"
	return
}
if {[string first # $c] != 1} {
	puthelp "NOTICE $nick :$::fzcom(logo): the channel $c doesn't seem valid as must start with an #" 
	return
}
As for validchan it doesn't care if the channel name is upper, lower or mixed case. Just tested this as wasn't 100% sure about it.

On a side note keep i mind that the validchan returns 1 only if the bot knows the channel, but isn't necessarily ON the channel at the said moment, so might want to extend it with botonchan to see if he's on the channel or not to avoid user confusion, meaning user will tell it to join, channel is known but for some reason (like bot's hostmask is banned, it's set to invite only or locked with some other mode, channel is set to +inactive, and whatnot) the bot can't join it and will attempt to add an existing channel and user won't see it join it.. thus creates some confusion. :)
Once the game is over, the king and the pawn go back in the same box.
G
Goga
Halfop
Posts: 83
Joined: Sat Sep 19, 2020 2:12 am

Post by Goga »

Ceaser Sir, can you please add this into fzcommands.tcl?
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Goga wrote:Ceaser Sir, can you please add this into fzcommands.tcl?
With our contributions, you have all the elements to add this part.
Can't you try by yourself before asking ? It's the better way to learn.
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this is what i came up with so far :

Code: Select all


"join" {
   if {![check:auth $nick $hand]} {return 0}
   if {![matchattr $hand n|n $chan]} {
    puthelp "NOTICE $nick :$fzcom(logo): You do not have access to use this command."
    return 0
   }
 if {[validchan $chan} {
      puthelp "NOTICE $nick :$::fzcom(logo): I'm already on $chan"
      return 0
   }
   if {![validchan $chan]} {
    channel add $chan
    puthelp "NOTICE $nick :$fzcom(logo):$chan added in my chanlist."
   } 
   return 0
  }

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

Post by CrazyCat »

nice try simo, but you made an error:
$chan is the chan where the command is typed, the destination chan is (we'll call it $c):

Code: Select all

set c [join  [lindex [split $arg] 0]]
s
simo
Revered One
Posts: 1080
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks crazycat yes i tested and saw what i did
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You don't need to do if {statement} and then do the same if but negate it like here:

Code: Select all

 if {[validchan $chan} {
      puthelp "NOTICE $nick :$::fzcom(logo): I'm already on $chan"
      return 0
   }
   if {![validchan $chan]} {
    channel add $chan
    puthelp "NOTICE $nick :$fzcom(logo):$chan added in my chanlist."
   } 
you can use if then else instead like this:

Code: Select all

if {[validchan $chan} {
	puthelp "NOTICE $nick :$::fzcom(logo): I'm already on $chan"
} else {
	channel add $chan
	puthelp "NOTICE $nick :$fzcom(logo):$chan added in my chanlist."
} 
And to extend the botonchan suggestion would be something easy like:

Code: Select all

if {[validchan $chan} {
	if {![botonchan $chan]} {
		puthelp "NOTICE $nick :$::fzcom(logo): $chan channel is in my chanlist, but for some reason I'm not on it."
	} else {
		puthelp "NOTICE $nick :$::fzcom(logo): I'm already on $chan"
	}
} else {
	channel add $chan
	puthelp "NOTICE $nick :$fzcom(logo):$chan added in my chanlist."
} 
You can take this one notch further and:
1. bind the need for op, unban, invite, limit, and key (basically bind need *) and store the actual need in a variable and you can know exactly what he needs.
2. and with a channel get see if channel is +inactive:

Code: Select all

if {[channel get $chan inactive]} {
	# your message here
}
Once the game is over, the king and the pawn go back in the same box.
Post Reply