eggdrop icon indicating copy to clipboard operation
eggdrop copied to clipboard

Receive messages send by 'putbot' commands with wildcard?

Open ZarTek-Creole opened this issue 4 years ago • 3 comments

Example of desired code leaf.tcl

# LEAF SEND SOMES PUTBOT WITH COMMANDS BEGIN WITH "ASK_" TO MyHub

putbot $MyHub "ASK_HELP MY_TEXT ARG"
putbot $MyHub "ASK_OK MY_TEXT ARG"
putbot $MyHub "ASK_ERROR MY_TEXT ARG"
putbot $MyHub "COMMAND MY_TEXT ARG"

hub.tcl

# bind bot with wildcard for capture all putbot with 'ASK_' on MyHub
bind bot - "ASK_*" BOT:LEAF:MSG:ASK
proc BOT:LEAF:MSG:ASK { SRC_BOT SRC_CMD Source_MSG } {
	set put_text	[lindex $Source_MSG 0]
	set put_arg		[lindex $Source_MSG 1]
	switch $SRC_CMD {
		ASK_HELP	-
		ASK_OK		{ putlog "I received ($SRC_BOT) '$put_command' : OK, '$put_arg' with arg '$put_arg'"}
		default		{ putlog "I received ($SRC_BOT) '$put_command' : command not found."}
	}
}

PROBLEM : "bind bot" NOT ACCEPT wildcard?

BOT bind bot <flags> <command> <proc>

procname <from-bot> <command> <text>

Description: triggered by a message coming from another bot in the botnet. The first word is the command and the rest becomes the text argument; flags are ignored.

Module: core

Docs binds "bind botm" does not exist for wildcard * LIKE 'PUBM' FOR 'PUB' with wildcard OR 'MSGM' FOR 'MSG' with wildcard)

MSGM (stackable) bind msgm <flags> <mask> <proc>

procname <nick> <user@host> <handle> <text>

Description: matches the entire line of text from a /msg with the mask. This is useful for binding Tcl procs to words or phrases spoken anywhere within a line of text. If the proc returns 1, Eggdrop will not log the message that triggered this bind. MSGM binds are processed before MSG binds. If the exclusive-binds setting is enabled, MSG binds will not be triggered by text that a MSGM bind has already handled.

Module: server

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 triggered by text that a PUBM bind has already handled.

Examples:

bind pubm * "#eggdrop Hello*" myProc
Listens on #eggdrop for any line that begins with "Hello"
bind pubm * "% Hello*" myProc
Listens on any channel for any line that begins with "Hello"
bind pubm * "% !command" myProc
Listens on any channel for a line that ONLY contains "!command"

Unwanted solution: Define for each putbot command a 'bind bot - <static_command> proc'

proposition of a solution: Create a 'botm' bind stackable

BOTM (stackable) bind botm <flags> <command> <proc>

procname <from-bot> <command> <text>

Description: matches the entire line of text across the botnet from a putbot with the mask. This is useful for binding Tcl procs to words or phrases spoken anywhere within a line of text. If the proc returns 1, Eggdrop will not log the message that triggered this bind. BOTM binds are processed before BOT binds. If the exclusive-binds setting is enabled, BOT binds will not be triggered by text that a BOTM bind has already handled.

Module: server

Any comments, improvement of ideas, suggestions are welcome.

Thanks for reading.

ZarTek-Creole avatar Oct 02 '20 13:10 ZarTek-Creole

Hi Malagam, thanks for the writeup. As you were asked to do in channel, could you please post an example of code with a wildcard that you would expect to work, that doesn't, complete with a log of the putbot messages being received by the bot? Thank you

vanosg avatar Oct 02 '20 15:10 vanosg

The feature request is for a wildcard-matching version of "bind bot", which does not currently support wildcards. The docs are not exactly clear on that.

thommey avatar Oct 02 '20 15:10 thommey

Do you still need information for this feature?

ZarTek-Creole avatar Feb 10 '21 16:02 ZarTek-Creole