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.

Adding a if variable?

Old posts that have not been replied to for several years.
Locked
g
galaxyboy

Post by galaxyboy »

Ok, I've got this part of the script. It's working perfectly alright. Right now, I need to add a 'if' variable so that if someone types !op nick, it works. However, if the command is not !op nick (such that it contains other words like !op #chan nick etc,) the bot would give a Syntax: !op <nick>

Here's the code:
bind pub o "[char]Op" pub:op
proc pub:op {user uhost hand chan arg} {
if {[lindex $arg 0] == "-help"} {
puthelp "NOTICE $user :02[char]OP02"
puthelp "NOTICE $user :Flags...: O"
puthelp "NOTICE $user :Syntax..: [cha]OP <nick>"
puthelp "NOTICE $user :0303"
puthelp "NOTICE $user :Info....: Give nick OP in #channel"
puthelp "NOTICE $user :This allows user to kick/ban/setmodes user in channel"
return 0
}
set opuser [lindex $arg 0]
if {[onchan $opuser $chan] == 0} {
puthelp "NOTICE $user :** Syntax: [char]OP <nick>"
puthelp "NOTICE $user :** $user isn't on channel"
return 0
}
putserv "PRIVMSG Q :set $chan strictops off"
puthelp "PRIVMSG $chan :eek:P for $opuser requested by $user"
putserv "MODE $chan +o :$opuser"
putserv "PRIVMSG Q :set $chan strictops on"
putlog "<$user> requested Op for $opuser in $chan"
}
Any ideas how do I add the 'if' variable? Thanks :smile:

<font size=-1>[ This Message was edited by: galaxyboy on 2001-12-01 02:09 ]</font>
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

if {[llength [split $arg]] > 1} {
Note, you are using strings on list commands in this script, which is a security risk and genraly bad progaming.

use [lindex [split $arg] IDX] instead.
g
galaxyboy

Post by galaxyboy »

What's the security risk about? If I would to change it to your suggestion, can you show me a full example? Thanks :smile:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Read 90% of the scripts in the egghelp.org archive, and you will see the proper use of it.

$arg comes from IRC as a string. And using a list command on a string in not the proper way (it's like trying to eat soup with a folk).
g
galaxyboy

Post by galaxyboy »

Err ppslim, I've look through most of the script but it seems like I couldn't find any. Could you just kindly give me some tips or show me what you are refering to? Thanks :smile:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

On 2001-12-04 02:13, galaxyboy wrote:
Err ppslim, I've look through most of the script but it seems like I couldn't find any.
Strange
Could you just kindly give me some tips
I allready did this int he first reply, use "split" on a string
or show me what you are refering to? Thanks :smile:
Look in the "eggdrop" forum, for the post related to [] in nicknames. This is an example of bad programming, because the programmer failed to use the "split" and "list" commands.
g
galaxyboy

Post by galaxyboy »

Ok ppslim, I'll look through that post. Next, I've got a problem. This is my first attempt in TCL programming and I'm not too sure about the spilt strings.

I've got this part of the script
bind pub o "[rmschar]kick" pub:kick
proc pub:kick {nick uhost hand chan arg} {
global botnick rmskick rmsquote
set kuser [string tolower [lindex $arg 0]]
set reason [lrange $arg 1 end]
set chkuser [nick2hand $kuser $chan]
if {[lindex $arg 0] == "-help"} {
puthelp "NOTICE $nick :02[rmschar]KICK02"
puthelp "NOTICE $nick :Flags...: o"
puthelp "NOTICE $nick :Syntax..: [rmschar]Kick <nick> <reason>"
puthelp "NOTICE $nick :0303"
puthelp "NOTICE $nick :Info....: Kicks a user out of the channel"
return 0
}
if {[llength [split $arg]] > 8} {
puthelp "NOTICE $nick :** Syntax: [rmschar]Kick <nick> <reason>"
return 0
}
if {$kuser == [string tolower $botnick]} {
puthelp "NOTICE $nick :Cannot kick myself"
return 0
}
if {[matchattr $chkuser +m] == 1} {
putserv "NOTICE $nick :Cannot kick +m flags"
return 0
}
if {$reason == ""} {
putserv "KICK $chan $kuser :$rmskick"
putlog "<$nick> requested kick on $chan to $kuser with default reason"
return 0
}
set rmsqt [lindex $rmsquote [rand [llength $rmsquote]]]
putserv "KICK $chan $kuser :$reason"
puthelp "NOTICE $nick :$rmsqt"
putlog "<$nick> requested kick on $chan to $kuser for $reason"
}
The previous OP script, I asked for how to add a if variable if the user types more than !op <nick>.

As for this script, I can't use that if variable. How do I add one such that if it's more than !kickban <nick> <reason>, it will trigger off a Syntax? I've tried using the previous if variable you recommended but it can't work because, if an oper reason exceed the length, it will trigger off the syntax. How do I use an if variable such that it doesn't trigger off no matter how long the <reason> is?

Thanks :smile:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

if {[llength [split $arg]] > 8} {
This line here is causing the problems.

change it to
if {([llength [split $arg]] > 2) || ([llength [split $arg]] < 2)} {
g
galaxyboy

Post by galaxyboy »

Err ppslim, it doesn't seems to work :smile: I replaced the line to
if {([llength [split $arg]] > 2) || ([llength [split $arg]] < 2)}
which you recommended but it still doesn't work :smile: I type !kick nickname out you go and it showed the Syntax :smile:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

I got up a little easrly today.

Code: Select all

if {[llength [split $arg]] < 2} {
Locked