PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Syphrone-NL on 05 May, 2005, 16:18:22

Title: script with one command
Post by: Syphrone-NL on 05 May, 2005, 16:18:22
Can somebody make me a script with one command:

!diner1

If you type that there should appear a message in pm with some tekst in it

I want to change the tekst and want to putt the tekst file in a folder.

Uses a bot

I want that i can change the folder name and the bot name.

thx in advanced
Title:
Post by: jiten on 05 May, 2005, 16:23:31
QuoteOriginally posted by Syphrone-NL
Can somebody make me a script with one command:

!diner1

If you type that there should appear a message in pm with some tekst in it

I want to change the tekst and want to putt the tekst file in a folder.

Uses a bot

I want that i can change the folder name and the bot name.

thx in advanced
Have you searched in Lua 5 Request/Help with and Finished Scripts Section? I've seen scripts that do that there.

Cheers
Title:
Post by: Syphrone-NL on 05 May, 2005, 16:45:01
Cant find it you got a link
Title:
Post by: jiten on 05 May, 2005, 17:00:13
Something like this (http://board.univ-angers.fr/thread.php?threadid=4352&boardid=28&styleid=1&sid=4ee1ebb0cec56bd7026a82c4f31a7a8e).

Cheers
Title:
Post by: Syphrone-NL on 05 May, 2005, 17:30:19
Almost

One little thing

I got the tekst file in a folder so can you add that folder thing to it please

So i need to fill in the folder and fill in the name of the tekst file
Title:
Post by: kepp on 05 May, 2005, 17:30:43
Or get guarding as it does exactly what you want + more
Title:
Post by: Syphrone-NL on 05 May, 2005, 17:34:38
got robocop and i only need that script
Title:
Post by: jiten on 05 May, 2005, 17:38:16
Try this too:
-- rules by jiten

sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "diner1.txt",
sFolder = "txt" -- folder where the file is stored
}

function Main()
frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner1"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end

function ReadFile(file)
local fFile = io.open(sConf.sFolder.."/"..file)
if fFile then
local message = fFile:read("*all");
fFile:close();
return message;
else
return file.." not found!"
end
end
Best regards
Title:
Post by: Syphrone-NL on 05 May, 2005, 17:47:19
thx alot
Title:
Post by: jiten on 05 May, 2005, 20:10:20
You're welcome...
Title:
Post by: Syphrone-NL on 05 May, 2005, 20:19:11
got an error when i want i do !dinner1

Syntax ...oftware\0.3.3.0.b16.09.nt.dbg\scripts\onecommand.lua:35: bad argument #2 to `sub' (number expected, got string)

How do i fix that
Title:
Post by: jiten on 05 May, 2005, 20:28:48
Bug fixed. Copy the script again.
Where's my head at? :D

Cheers
Title:
Post by: Syphrone-NL on 05 May, 2005, 20:37:31
weird now i dont get anything
Title:
Post by: jiten on 05 May, 2005, 20:49:28
Post updated ;)
Title:
Post by: Syphrone-NL on 05 May, 2005, 20:57:57
Finally its works great


I tryed now seven commands lol for fun

I tryed this:
sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "diner1.txt",
sFile2 = "diner1.txt",
sFile3 = "diner1.txt",
sFile4 = "diner1.txt",
sFile5 = "diner1.txt",
sFile6 = "diner1.txt",
sFile7 = "diner1.txt",
sFolder = "txt" -- folder where the file is stored
}

function Main()
frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner7"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner1"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner2"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile2))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner3"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile3))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner4"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile4))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner5"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile5))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner6"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile6))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end

function ReadFile(file)
local fFile = io.open(sConf.sFolder.."/"..file)
if fFile then
local message = fFile:read("*all");
fFile:close();
return message;
else
return file.." not found!"
end
end

But that doesnt work
Maybe some can tell my why???
I think because i dont know how make a script
Title:
Post by: Dessamator on 05 May, 2005, 21:24:43
QuoteOriginally posted by Syphrone-NL
But that doesnt work
Maybe some can tell my why???
I think because i dont know how make a script

well, uve answered the question by urself, "I think because i dont know how make a script", u cant just make a new ChatArrival for each command u add, it just doesnt work that way, :)
Title:
Post by: Syphrone-NL on 05 May, 2005, 21:33:09
Can you help me a little bit forward???
Title:
Post by: jiten on 05 May, 2005, 21:39:28
Change ur code to this pattern:
function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner1"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
end,

...


["diner7"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end


Cheers
Title:
Post by: Syphrone-NL on 06 May, 2005, 07:50:46
Cool got it

sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "diner1.txt",
sFile2 = "diner1.txt",
sFile3 = "diner1.txt",
sFile4 = "diner1.txt",
sFile5 = "diner1.txt",
sFile6 = "diner1.txt",
sFile7 = "diner1.txt",
sFolder = "txt" -- folder where the file is stored
}

function Main()
frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner1"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
end,

["diner2"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile2))
end,

["diner3"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile3))
end,

["diner4"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile4))
end,

["diner5"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile5))
end,

["diner6"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile6))
end,

["diner7"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end


function ReadFile(file)
local fFile = io.open(sConf.sFolder.."/"..file)
if fFile then
local message = fFile:read("*all");
fFile:close();
return message;
else
return file.." not found!"
end
end
Title:
Post by: jiten on 06 May, 2005, 12:52:43
Nice to know it.

Cheers

PS: I'd be better for u use to use the Rotating Message script if you wanted them to be posted after x minutes.
Title:
Post by: Syphrone-NL on 06 May, 2005, 20:43:42
The rotating message is for a 24 hour rotating so after 24 hours there comes 1 tekst file with a message for a meal in it how to make the meal. But if the users want to see the meal on a other time they use that script
Title:
Post by: Syphrone-NL on 26 May, 2005, 17:59:33
Can somebody make me a little thing in the little script that if somebody uses the command his nick and the command he used  are send to opchat also
Title:
Post by: Syphrone-NL on 26 May, 2005, 18:00:19
Can somebody make me a little thing in the little script that if somebody uses the command his nick and the command he used  are send to opchat also

script
sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "diner1.txt",
sFile2 = "diner1.txt",
sFile3 = "diner1.txt",
sFile4 = "diner1.txt",
sFile5 = "diner1.txt",
sFile6 = "diner1.txt",
sFile7 = "diner1.txt",
sFolder = "txt" -- folder where the file is stored
}

function Main()
frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner1"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
end,

["diner2"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile2))
end,

["diner3"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile3))
end,

["diner4"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile4))
end,

["diner5"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile5))
end,

["diner6"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile6))
end,

["diner7"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end


function ReadFile(file)
local fFile = io.open(sConf.sFolder.."/"..file)
if fFile then
local message = fFile:read("*all");
fFile:close();
return message;
else
return file.." not found!"
end
end
Title:
Post by: Markitos on 26 May, 2005, 18:16:47
QuoteOriginally posted by Syphrone-NL
Can somebody make me a little thing in the little script that if somebody uses the command his nick and the command he used  are send to opchat also

script
sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "diner1.txt",
sFile2 = "diner1.txt",
sFile3 = "diner1.txt",
sFile4 = "diner1.txt",
sFile5 = "diner1.txt",
sFile6 = "diner1.txt",
sFile7 = "diner1.txt",
sFolder = "txt" -- folder where the file is stored
}

function Main()
frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["diner1"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
end,

["diner2"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile2))
end,

["diner3"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile3))
end,

["diner4"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile4))
end,

["diner5"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile5))
end,

["diner6"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile6))
end,

["diner7"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end


function ReadFile(file)
local fFile = io.open(sConf.sFolder.."/"..file)
if fFile then
local message = fFile:read("*all");
fFile:close();
return message;
else
return file.." not found!"
end
end

I didn't understand...Can u explain better???
Title:
Post by: Syphrone-NL on 26 May, 2005, 20:30:15
If a user types !diner1 he gets a message in pm with a tekst

But i want that if the user uses that that the bot also sends a message to opchat with something like:

[user] uses the command !diner1
Title:
Post by: jiten on 26 May, 2005, 20:46:53
QuoteOriginally posted by Syphrone-NL
If a user types !diner1 he gets a message in pm with a tekst

But i want that if the user uses that that the bot also sends a message to opchat with something like:

[user] uses the command !diner1
Something like !cmdspy in Robocop, isn't it?
Change this part:
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end

with:
if tCmds[cmd] then
return tCmds[cmd](user,data), SendPmToOps(frmHub:GetOpChatName(),os.date().." - "..user.sName.." used command !"..cmd), 1
end
Btw, have a look at Rotating Message. It's more efficient and complete now (this code has a lot of repetition).

Cheers