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.

MASK

Help for those learning Tcl or writing their own scripts.
Post Reply
L
Lu5ck
Halfop
Posts: 43
Joined: Thu Dec 07, 2006 8:58 am

MASK

Post by Lu5ck »

Hi all,

It my first time writing a TCL script.

I wanna ask, is the MASK inside the bind accept the same thing Normal IRC does?

Will this work?

Code: Select all

bind PUBM - /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/g CallMain
If it don't can anyone point me to a site that contain all the matching command?

The above "/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/g" is actually meant to react if someone spammed a ip address like 21.203.203.11
Well, I did that for my IRC script, but I trying to convert the coding to TCL ones.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

bind masks do not support regular expressions, but only simple wildcards supported by "string match", ie ?, *, [chars], \x

? would match any single character
* would match any number of characters
[chars] would match any single character of the ones in chars, also supports intervals such as a-z
\x would match the single character x (used for escaping special characters such as ?*[]\)

The closest thing you could use would be something like this: "*.*.*.*", but that would match anything said that has three or more dots in it...
If you really wish to use regular expressions, considder doing the matching within the CallMain proc, rather than doing it in the binding.. regexp is your friend here
NML_375
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Also % matches a single word (no white spaces).
L
Lu5ck
Halfop
Posts: 43
Joined: Thu Dec 07, 2006 8:58 am

Post by Lu5ck »

Thanks :D

Ermm...

Sorry but...

What is the variable for the channel message in variable?

I know nick is $nick, channel name is $channel, wat about the channel message? Is it $pubm ?
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

(6) PUBM (stackable)
bind pubm <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <text>

Description: just like MSGM, except it's triggered by things said
on a channel instead of things /msg'd to the bot. The mask is
matched against the channel name followed by the text and can
| contain wildcards. If the proc returns 1, Eggdrop will not log
| the message that triggered this bind. PUBM binds are processed
| before PUB binds. If the exclusive-binds setting is enabled,
| PUB binds will not be trigged by text that a PUBM bind has
| already handled.
Module: irc


Assuming your proc used the above example format, your msg would be inside of $text
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Tcl-commands.doc:
PUBM (stackable)
bind pubm <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel> <text>

Description: just like MSGM, except it's triggered by things said
on a channel instead of things /msg'd to the bot. The mask is
matched against the channel name followed by the text and can
contain wildcards. Also, if a line triggers a PUB bind, it will not
trigger a PUBM bind.
Module: irc
You can name them whatever you want as long as the number of attributes is correct.
L
Lu5ck
Halfop
Posts: 43
Joined: Thu Dec 07, 2006 8:58 am

Post by Lu5ck »

Yah, i mean inside the proc

how can I get the message string?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Didn't you read what me and rosc2112 showed you? look close and notice the <text> parameter. There are loads and loads of examples in this forum, search.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Then considder this example:

Code: Select all

bind pubm - * myproc

proc myproc {arg1 arg2 arg3 arg4 arg5} {
 putlog "myproc was called by $arg1 from host $arg2 identified as $arg3 on channel $arg4 saying $arg5"
}
Just as Sir_Fz said, it really does'nt matter what you call those parameters..
You just specify which arguments your proc should take. Once you call your proc with:

Code: Select all

myproc "the nick" "the host" "the handle" "the channel" "the text"
these values will be assigned to local variables within the proc, named as you specify in the header (in this example arg1, arg2, arg3, arg4, arg5).

All "bind" does is calling whatever command-line you specified (in this example "myproc"), with a number of arguments (5 arguments for the pubm binding) holding various information on the event that triggered the binding
NML_375
L
Lu5ck
Halfop
Posts: 43
Joined: Thu Dec 07, 2006 8:58 am

Post by Lu5ck »

THANKYOU nml375

For the clear explaination on these argument

I don't really understand the documentation
Post Reply