| View previous topic :: View next topic |
| Author |
Message |
Goga Halfop
Joined: 19 Sep 2020 Posts: 78
|
Posted: Tue Jan 05, 2021 6:24 am Post subject: Join Module |
|
|
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 |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Tue Jan 05, 2021 7:21 am Post subject: |
|
|
That's quite the same.
As I don't know your full script, here is the basic version
| Code: |
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]
} |
_________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
Goga Halfop
Joined: 19 Sep 2020 Posts: 78
|
Posted: Wed Jan 06, 2021 12:37 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Jan 06, 2021 2:06 am Post subject: |
|
|
| Code: |
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: |
bind pub n|n !join makejoin
|
Instead of:
| Code: |
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: |
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. |
|
| Back to top |
|
 |
Goga Halfop
Joined: 19 Sep 2020 Posts: 78
|
Posted: Wed Jan 06, 2021 4:59 am Post subject: |
|
|
| Ceaser Sir, can you please add this into [url]fzcommands.tcl[/url]? |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Wed Jan 06, 2021 6:29 am Post subject: |
|
|
| Goga wrote: | | Ceaser Sir, can you please add this into [url]fzcommands.tcl[/url]? |
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. _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Jan 06, 2021 5:17 pm Post subject: |
|
|
this is what i came up with so far :
| Code: |
"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
}
|
|
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Wed Jan 06, 2021 6:56 pm Post subject: |
|
|
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: | | set c [join [lindex [split $arg] 0]] |
_________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Jan 06, 2021 7:40 pm Post subject: |
|
|
| thanks crazycat yes i tested and saw what i did |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Jan 07, 2021 2:13 am Post subject: |
|
|
You don't need to do if {statement} and then do the same if but negate it like here:
| Code: |
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: |
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: |
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: |
if {[channel get $chan inactive]} {
# your message here
}
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
|