egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Join Module

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Goga
Halfop


Joined: 19 Sep 2020
Posts: 78

PostPosted: Tue Jan 05, 2021 6:24 am    Post subject: Join Module Reply with quote

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
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Tue Jan 05, 2021 7:21 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Goga
Halfop


Joined: 19 Sep 2020
Posts: 78

PostPosted: Wed Jan 06, 2021 12:37 am    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Jan 06, 2021 2:06 am    Post subject: Reply with quote

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. Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Goga
Halfop


Joined: 19 Sep 2020
Posts: 78

PostPosted: Wed Jan 06, 2021 4:59 am    Post subject: Reply with quote

Ceaser Sir, can you please add this into [url]fzcommands.tcl[/url]?
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Wed Jan 06, 2021 6:29 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Jan 06, 2021 5:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Wed Jan 06, 2021 6:56 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Jan 06, 2021 7:40 pm    Post subject: Reply with quote

thanks crazycat yes i tested and saw what i did
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Thu Jan 07, 2021 2:13 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber