Wiseguy from lua4 2 lua5 << need some help - Page 2
 

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

Wiseguy from lua4 2 lua5 << need some help

Started by kuipie, 27 March, 2005, 23:09:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Syphrone-NL

QuoteOriginally posted by jiten
QuoteOriginally posted by Syphrone-NL
Does anybody has the good working wiseguy????????

Well, there's a working one. Search the forum for "Clever Janinha" and then see if it suits ur needs  :]

Best regards,

jiten

cant find it
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

Check this  thread.

Cheers

Dessamator

--[[
	Thks to Ptaczek for his Trickerbot.lua
	Thks to Skrollster, for the math.random synthax
	Thks to MatrixX for some help, too...
	And thks to the others, for their help... ;o)
----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
	seNsi: the 'clever' bot :p
	Description:
	- Each 20 math.min, bot is talking alone, with math.random questions...
	- If someone speaks again on main chat, there is a math.random answer, and then the timer is starting again.
	- If the user says a known trig (ex: 'hey '), and the bot was feeling alone, bot will choose the correct answer (ex:'Yessss,...[USER] happy to hear U again,, :))')
	- Sorry for the 'a' synthax (a = 0, a = 1, etc...), but I'm quite nb in lua...
	- Hope u'll enjoy it ! :o)
----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
	- heavily touched by Herodes :: 28/3/2005 ( 16.08 compliant too )
	- many optimizations .. couldn't count them .. just enjoy..
	- some fixes by Dessamator
--]]
bot = {
	["name"] = "SenSi",
	["email"] = "petsagouris@hotmail.com",
	["desc"] = "I am the cleverest bot around ...",
}

Interval = 1 -- every how many minutes ?

s = {}
s.trigs = {
	["bye"] = "See ya [USER]",
	["fine u"] = "I am lame... ",
	["need some"] = "Hum... maybe pray for it...",
	["loool"] = "Yeah, [USER] ! It was really funny...",
	["its fine"] = "good...",
	["take care"] = "U 2... :o)",
	}

s.idle ={} -- don't touch this line pls .. if you do don't blame it on me ..

s.idle.questions = {
	"Anybody here?",
	"I'am Boored",
	"All are sleeping ?!",
	"Haaaaaaaaloooooooooo !!! ",
	"Don't leave me alone.... :'(",
	}

s.idle.answers = {
	"Aaaahh, dear [USER]... i was feeling quite alone.... :o)",
	"Yessss,...[USER] happy to hear U again,, :))",
	"Sorry to disturb u, [USER], but i was quite upset... :s ",
	"Thks, [USER]... i thought something was wrong with ur keyboard...",
	"OOhhh, [USER]... i'm not alone at this universe... :))"
	}

s.idle.morninganswers = {
	"Wow... [USER]... ur night was certainly short.... :p",
	"Yeahh !!! GOOOOOD MORNIIIIIIIIIING [USER] !",
	"So, [USER],...coffee for me please, yep... :o)"
	}

s.idle.morning = {
	"Driiiiiiing... Time to Wake Uuuuuuuuuuup !! :D",
	"GOOOOOD MORNIIIIIIIIIING HUBSTERRRRRRRRRRRRRS !!!!!!!",
	"Hmm.....Someone is awake ??!!"
	}

s.idle.evening = {
	"Time to have a drink, no ? :o)",
	"Hum hum... place is really quiet, at this time... :'(",
	"At this time, u shouldn't sleep... :-("
	}

s.idle.eveninganswers = {
	"Well, at least... Some of us are still alive,... cool :D",
	"I was upset,... that's all... :(",
	"It's time...If u offer me a drink... i couldn't say no.... :p"
	}



function Main()
	talk = true
	frmHub:RegBot(bot.name, 1, bot.desc, bot.email)
	bot = bot.name
	w = { ["quiet"] = false,["morn"] = false,["even"] = false }
	SetTimer(Interval*60000)
	StartTimer()
end

function ParseCommands(user, data, pm_start)
	local findstr = (pm_start or "").."%b<>%s+[!#?+](%S+)"
	local _,_, cmd = string.find ( data, findstr )
	if cmd then
		if cmd == "quiet" then
			Talk(false)
			SendToAll(bot, "Ok,... "..user.sName.." told me to be quiet ... that's what I'll do... :s")
			StopTimer()
		elseif cmd == "talk" then
			Talk(true)
			SetWait(false,false,false)
			StartTimer()
			SendToAll(bot, "Ahh... i'm back :)")
		end
		return true
	else
		return false
	end
end

function Talk(b)
	if b then talk = b end
	return talk
end

function ToArrival(user, data)
	if (string.sub(data, 1, string.len(bot)+5 ) == "$To: "..bot ) then
		if user.bOperator then
			if ParseCommands(user, string.sub(data,1, -2), "%$") then
				return 1
			end
		end
	end
end

-- Main Chat events --
function ChatArrival(user, data)
	if ( user.bOperator and ParseCommands( user, string.sub(data,1, -2) ) ) then return 1 end
	local _,_,msg = string.find( data, "%b<>%s*(.*)|")
	local talked = nil
	msg = string.lower(msg)
	for trig, replace in s.trigs do
		if ( w.quiet == false) then
			if string.find( msg, trig ) then
				talked = (Produce( replace, "%[USER%]", user.sName))	
			--	break;
			end
		end
	end
	if talked then
		SendToAll( user.sName, msg)
		SendToAll( bot, talked )
		return 1
	end

	-- Restart the timer each time someone is talking on the main chat, if bot is allowed to talk --
	if Talk() then
local function idleresponce(idle)
	dostuff=Produce( idle, "%[USER%]", user.sName)
	return dostuff
end	
		StopTimer()
		StartTimer()
		if w.quiet then
			SendToAll(bot, idleresponce(s.idle.answers ))
			SetWait(false)	
		elseif 	(w.morn) then
			SendToAll(bot, idleresponce(s.idle.morninganswers))
			SetWait(false,false)
		elseif w.even then 
			SendToAll(bot, idleresponce(s.idle.eveninganswers))
			SetWait(false,false,false)
	
		end
	end
end


function OnTimer()
	local h, trig = tonumber(os.date("%H")), nil
	-- Idle trigs, for the morning, and the evening :o) --
	if h == 7 then
		SendToAll( bot, Produce(s.idle.morning) )
		SetWait(false,true,false)
		StartTimer()
		trig = true
	elseif h == 19 then
		SendToAll( bot, Produce(s.idle.evening) )
		SetWait(false,false,true)
		StartTimer()
		trig = true
	end

	-- Others idle trigs --
	if not trig then
		SendToAll( bot, Produce(s.idle.questions))
		SetWait(true)
	end
end

function Produce( val, what, with )
	if what then
		if type(val) == "table" then
			return string.gsub( val[math.random(1,table.getn(val))], what, with )
		end
		return string.gsub( val, what, with )
	end
	return val[math.random(1,table.getn(val))]
end

function SetWait( q, m, e )
	w.quiet = q --quiet
	w.morn  = m --morning
	w.even  = e --evening
end--------------------------------------------------------------------------------

all errors fixed, debugged, and tested 100%, ;)
Ignorance is Bliss.

yoonohoo

#28
Why does the bot reply before my comment?

04:01:47] All are sleeping ?!
[04:02:44] Aaaahh, dear bcdc... i was feeling quite alone.... :o)
[04:02:44] no
The red reply should be here!?

Tried also janinha...same.

It might be simple for you but rocket science for me...

jiten

QuoteOriginally posted by yoonohoo
Why does the bot reply before my comment?

04:01:47] All are sleeping ?!
[04:02:44] Aaaahh, dear bcdc... i was feeling quite alone.... :o)
[04:02:44] no
The red reply should be here!?

Tried also janinha...same.
Well, search the forum for "senSi" by Dessamator. It should solve that problem.
Btw, that report of yours seems strange to me. I had already fixed that in Janinha. Anyway....

Cheers

SMF spam blocked by CleanTalk