Trickerbot priority trouble
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Trickerbot priority trouble

Started by ??Empie??, 05 November, 2003, 16:33:37

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

??Empie??

I've implemented this (good old) trickerbot from ptazeck into my own script, but if there are 2 or more triggerwords in 1 sentence it always chooses a particulair one.

I want some words to have top priority, but I havent got a clue how the script chooses which of the triggers to respond to if there are more then one in a sentence.

Could anyone please help me :)

Here's a copy of the script:

-- TrickerBot2.lua, created by Ptaczek Dec-24, 2002
-- Just see how to implement the NMDC TriggerBot in LUA :)

-- changes
-- Feb-24, 2003, v2.0 Modification for DataArrival return value.

botname = "TrickerBot"
trigs = {
		lol="Yeah, that was funny [USER]. Haha.",
		bye="See ya [USER]",
		vandel="Vandel!?!? WHERE??!",
		ptokax="Oh Yeah, PtokaX ;)",
		fuck="Watch IT [USER]! One more line of code and i could kick your ass!",
		["shut up"]="Make me!",
		["+ops"]="Open your eyes guys and look at the userlist!"
	}
	

function Main()
	frmHub:RegBot(botname)
end

function DataArrival(user, data)
	if( strsub(data, 1, 1) == "<" ) then
		-- get the msg only using regular expression
		s,e,msg = strfind(data, "%b<> ([ -z]*)")

		-- look in the table
		for key, value in trigs do
			if( strfind( strlower(msg), key) ) then
				answer, x = gsub(value, "%b[]", user.sName) 
				SendToAll( data ) -- send the original data
				SendToAll( botname, answer ) -- send bot's answer
				return 1 -- tell the hub we have processed the data
			end
		end
	end
end

pHaTTy

it responds to the first in the line for example

Hi bollox

now Hi will reply Hello or so
and bollox will reply bollox what

so Hi was first so it will reply hello

if Bollox hi it will reply bollox what

phatty
Resistance is futile!

OpiumVolage

he reply to the first he find in the trigs table:
for key, value in trigs do

Problem is that i don't know if we can sort this table as it's an associative table. Try to change the order when you define the triggers:

this:

trigs = {
lol="Yeah, that was funny [USER]. Haha.",
bye="See ya [USER]" }

could behave differently that:

trigs = {
bye="See ya [USER]",
lol="Yeah, that was funny [USER]. Haha." }

But not really confident :)

??Empie??

#3
Actually, it doesnt.

I'll use your example:

if I say Hi Bollox

and the script replies hello

then I say Bollox Hi

then the script will reply hello to, as if Hi overrules the Bollox...

thats the weirdness. I dont know what overrules what... I've tested on te the following possibilities:

the trigger thats first in line is first: negative
the trigger thats first in script: negative
the trigger that is shortest: negative
the trigger that is first in alphabeth: negative

so Im clueless  ?(

@ OpiumVolage
Thats not it too.. it just seems to have its own will in finding what trigger has top priority  :(

pHaTTy

dumb question : but did you insert bollox as a trigger?
Resistance is futile!

OpiumVolage

here is the problem, with the order defined before:
trigs = {
		lol="Yeah, that was funny [USER]. Haha.",
		bye="See ya [USER]",
		vandel="Vandel!?!? WHERE??!",
		ptokax="Oh Yeah, PtokaX ;)",
		fuck="Watch IT [USER]! One more line of code and i could kick your ass!",
		["shut up"]="Make me!",
		["+ops"]="Open your eyes guys and look at the userlist!"
	}

for key, value in trigs do print(key) end

Results:

lol
vandel
+ops
bye
ptokax
fuck
shut up

??Empie??

I now tried it with a new set of triggers... Long, short, in order, not in order, but I still cant find out how ptokax desides its priority...

It cant be this difficult you'd say. PtokaX somewhere must choose on which trigger to react first by a certain mechanism, but I cant find it... :(

If nobody can help, this will go in my book of unsolved riddles, but I still hope somebody can tell me how it works :)

SMF spam blocked by CleanTalk