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.

Is it possible?

Old posts that have not been replied to for several years.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Is it possible?

Post by metroid »

To make a script where you specify rules and if someone breaks one you can do for example : !kick <nick> <rule number> | !kick MeTroiD 2
* MeTroiD was kicked by <bot> (You have broken rule 2: Don't flood)

I came up with something like this but i don't know how i have to make it see <nick> and then after it the number...

Code: Select all

bind pub o !kick pub:qkick 

set one "Rule 1 | TEST"
set two "Rule 2 | TEST"
set three "Rule 3 | TEST"

proc pub:qkick {nick uhost hand chan text} { 
if {[string length $text] > 0} { set tnick [lindex $text 0] }
set userhost [getchanhost $tnick $chan] 
set tnick [lindex $text 0]
if {[botisop $chan]} { 
if {$text == "1"} {
putquick "KICK $chan $tnick :$::one"
} elseif {$text == "2"} {
putquick "KICK $chan $tnick :$::two"
	}
}
}
If someone could tell me how it works (if you know what i mean that is :P)
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

There are many ways todo this. One of the easiest way is to match
the numbers in the text with certain numbers you have defined in
your procedure.

Umm, try this... it should definately work:

Code: Select all

bind pub o !kick pub:qkick 

set one "Testing... Rule 1"
set two "Testing... Rule 2"
set three "Testing.... Rule 3"

proc pub:qkick {nick uhost hand chan text} { 
 global botnick one two three
  if {([string length $text]) < 1} { return 0 } 
  set user [lindex $text 0] ; set reason [lindex $text 1]
  if {([botisop $chan])} { 
   if {($reason == "1")} { 
    putquick "KICK $chan $user :$one" -next
    } if {($reason == "2")} { 
    putquick "KICK $chan $user :$two" -next
    } if {($reason == "3")} { 
    putquick "KICK $chan $user :$three" -next
    } 
  } 
}
With this code you will have to use the following
format of command:

Code: Select all

!kick <nick> <1|2|3>
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Tcl error [pub:qkick]: wrong # args: no expression after "if" argument

This is the error i had but when i changed the } if to } elseif it worked fine :)
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Oh yeah my mistake pasted it in a hurry. 8)

If you have alot of conditions, to satisfy or vice
versa, use... if then elseif.... and else in the end.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

I should be able to put this at the bottom

Code: Select all

} else {
putquick "NOTICE $nick :Usage : !kick <nick> <rule>"
Right? :)
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Yeah... thats a good way of making public command
scripts more user friendly.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

An alternative to a lot of if's and else's is switch. Doing strikelight's tests the if's seem to be a bit faster than the switch, but switch offers a better *look* than a bunch of if's and elses. If you want a lil bit more speed but no *look* then stick to if's. :mrgreen: The *difference* betwen them has been discussed here. Scroll a bit down and read strikelight's post.
Once the game is over, the king and the pawn go back in the same box.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

I have another odd question, I made this script but what i was wondering was if it could pick up lines during the proc. The script i made is here :

Code: Select all

bind pub o|o !addop pub:addop:q

proc pub:addop:q {nick uhost hand chan text} { 
if {[string length $text] > 0} { set tnick [lindex $text 0] }
if {[onchan "Q" $chan]} { 
putquick "NOTICE $nick :Note: I need atleast the +aom(n) flags for this command to work."
putquick "PRIVMSG Q :chanlev $chan $text"
putquick "NOTICE $nick :Done."
putquick "MODE $chan +o $tnick"
putquick "NOTICE $tnick :$text is/are your new flag(s) in Q."
} elseif {[onchan "L" $chan]} { 
putquick "NOTICE $nick :Note: I need atleast the +aom(n) flags for this command to work."
putquick "PRIVMSG L :chanlev $chan $text"
putquick "NOTICE $nick :Done."
putquick "MODE $chan +o $tnick"
putquick "NOTICE $tnick :$text is/are your new flag(s) in L"
	}
}

bind pub o|o !rop pub:rop:q

proc pub:rop:q {nick uhost hand chan text} { 
if {[string length $text] > 0} { set tnick [lindex $text 0] }
if {[onchan "Q" $chan]} { 
putquick "NOTICE $nick :Note: I need atleast the +aom(n) flags for this command to work."
putquick "PRIVMSG Q :chanlev $chan $text"
putquick "NOTICE $nick :Done."
putquick "MODE $chan -o $tnick"
putquick "NOTICE $tnick :You have been removed from Q by $nick."
} elseif {[onchan "L" $chan]} { 
putquick "NOTICE $nick :Note: I need atleast the +aom(n) flags for this command to work."
putquick "PRIVMSG L :chanlev $chan $text"
putquick "NOTICE $nick :Done."
putquick "MODE $chan -o $tnick"
putquick "NOTICE $tnick :You have been removed from L by $nick."
	}
}
putlog "add Q\L flags script by \002MeTroiD\002 loaded."
What I would like it to pick up is, if this command is used but the bot has no access in the service bot Q/L which tells you "You are not known or banned on this channel and can't dump the userlist!" And L tells you "Sorry, you do not have permission to view/change user flags on <channel>"

If you don't have access, What i was wondering is if it possible for the bot to look for these commands when either one of these commands are used. Cos if it detects one of the lines it should say in the channel that he has no access to the service bot on that channel. But i have no clue how or if its possible for the bot to look for either one of these lines.

-Edit : The script works fine btw, i was just wondering if it was possible :)
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

For the thing which you are trying to say, and if I understand correctly.

You want the bot to execute commands of a network services, and if the service denies and says you do not have access, it should show it on the channel.

You can bind a trigger whether your networks services does a msg, or notice to a bind of a procedure match certain texts with wildcards of having no access with your services nick, and then return 0 or privmsg $chan or whatever.

There is no way you can trigger pub with bind msg or notice, you will need a seperate procedure.

Like on DALnet if you use ChanServ WHY <#channel> <nick> gives results:
if "* has * access *" (awyeah has <FOUNDER|SOP|AOP> access to)
if "* has NO access *" (awyeah has NO access to)
(You can use this type of string matching with wildcards)

Also you will need several conditions, like only if the $nick is your services
nick, also maybe match the user@host and botisop $chan etc.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Thnx, ill have a go at it :)
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

nvm this post, i've given up on the string match stuff :(
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

You can use:

Code: Select all

EXAMPLE
([string match -nocase *pattern here* text-to-match])
It will be something like:

Code: Select all

if {([string match -nocase "* has * access to *" $text])} {
Where the matching procedure word is between
the quotation marks " and ".

Replace the matching pattern with your services reply.

Always remember this:
* = matches a single word
? = matches a single character
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

I'll give it a try ( btw i made a nice proc etc but it didnt work properly )
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

bind pub o|o !addop pub:addop:q

proc pub:addop:q {nick uhost hand chan text} { 
if {[string length $text] > 0} { set tnick [lindex $text 0] }
if {[onchan "Q" $chan]} {
if {([string match -nocase "* master *" $text])) ( return )
putquick "NOTICE $nick :Note: I need atleast +aom(n) flags for this command to work."
putquick "PRIVMSG Q :chanlev $chan $text"
putquick "NOTICE $nick :Done."
putquick "MODE $chan +o $tnick"
putquick "NOTICE $tnick :$text is/are your new flag(s) in Q."
} elseif {[onchan "L" $chan]} { 
if {([string match -nocase "* master *" $text])) ( return )
putquick "NOTICE $nick :Note: I need atleast +aom(n) flags for this command to work."
putquick "PRIVMSG L :chanlev $chan $text"
putquick "NOTICE $nick :Done."
putquick "MODE $chan +o $tnick"
putquick "NOTICE $tnick :$text is/are your new flag(s) in L"
	}
}
This should check if it recieves a reply first right? And if it does get a reply with the word Master in it, It should just stop
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

[15:38] Tcl error [pub:rop:q]: syntax error in expression "([string match -nocase "* master *" $text])) ( return )
[15:38:27] <sheeptest> putq...": extra tokens at end of expression
Thats the error i get :E
Locked