Hi
I wanne make a faq bot, and I've seen a very good bot form Mutor the Send file 1.1 (http://board.univ-angers.fr/thread.php?threadid=5001&boardid=26&sid=e9e32e127df0fafee20998b3dac5cb3a) Bot.
the disadvantage of this bot for me, is that an OP have to send a file to a user...
The thing I wanne fix is that a user can see with a command witch faqs ther are, and read it with another command.
I am a newbie here, and I've tried to fix it.
But haven't succeeded me...
This is what I got:
- Faq Bot (First Script)
-- By Leun
-- 20-8-2005
-- thanks to Mutor for the work in
-- -- Made by by Mutor The Ugly 7/15/05
-- -- Script: SendFile 1.1 LUA 5
---------------------------------------------------
-- Usage:
-- #faqs - Show the Faq
-- #faqslist - Show alle de Faqs
--
----------------------------------------------------
-- ## SETTINGS ##--
Bot = "FistBOT"
-->> commands
SendCmd = "#faqs"
ListCmd = "#faqlist"
-->> FilePath
FilePath = ""..\\texts\\"
-- Menu name pulled form hub, uses hub name for menu
vMenu = "FaQ"
-- Who may use this command/receive context menu
Profiles = {
[-1] = 0, --Unregistered User
[0] = 0, --Master
[1] = 0, --Operator
[2] = 0, --Vip
[3] = 0, --Registered User
[4] = 0, --Moderator
[5] = 1, --NetFounder
}
-- ## End of Settings ##--
PM=0
function Main()
frmHub:RegBot(Bot)
end
NewUserConnected = function(user)
if UserCommands == 1 and tLevels[user.iProfile] == 1 then
user:SendData("$UserCommand 1 3 "..vMenu.."\\Use a faq$<%[mynick]> #faqs %[line:name]||")
user:SendData("$UserCommand 1 3 "..vMenu.."\\Show all faqs$<%[mynick]> #faqlist|")
end
end
OpConnected=NewUserConnected
function ChatArrival(user, data)
data=string.sub(data,1,-2)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
data = string.sub(data,string.len(cmd)+2,-1)
local s,e,text = string.find(data,"%s+(%w+)")
if (cmd==SendCmd) then
local usrnick = GetItemByName(nick)
if not usrnick then
local reply = "File doesn't exist check your spelling"
user:SendData(reply)
return 1
elseif Profiles[user.iProfile] == 1 then
if cmd and text then
PM=0
GetFile(user,text)
else
local syntaxerr = "Syntax Error\tCommand Syntax= <"..SendCmd.."> "..
" (file extension not required)"
user:SendData(sytaxerr)
end
else
SendToNick(user.sName,"Sorry "..user.sName..", your not allowed use of the "..SendCmd.." command.")
return 1
end
return 1
end
if (cmd==ListCmd) then
if Profiles[user.iProfile] == 1 then
DoList(user)
return 1
else
SendToNick(user.sName,"Sorry "..user.sName..", your not allowed use of the "..ListCmd.." command.")
return 1
end
end
end
But it is verry fault I know..
Can someone help me? ?(
thnx for your help,
I will give it a try.
Hi,
I know this script is redundant, but I wanna try change it
also for learing...
But it failed..
I get this massege in main by commend +send test;
<[BOT]Test> The file ..\texts\nd.txt does not exist, check your settings.
That are the last two letters of send...
This is what I got now;
-- Faq Bot (First Script)
-- By Leun
-- 20-8-2005
-- thanks to Mutor for the work in
-- -- Made by by Mutor The Ugly 7/15/05
-- -- Script: SendFile 1.1 LUA 5
---------------------------------------------------
-- Usage:
-- #faqs - Show the Faq
-- #faqslist - Show alle the Faqs
--
----------------------------------------------------
-- ## SETTINGS ##--
--Send command
SendCmd = "+send"
--List command
ListCmd = "+faqlist"
--Path to textfiles(s) (PtokaX text reader folder = "..\\texts\\")
FilePath = "..\\texts\\"
--Name for bot
Bot = "SendFile1.2"
-- Menu name pulled form hub, uses hub name for menu
rMenu = "FaQ"
-- Custom submenu
SubMenu ="FaQ"
-- Who may use this command/receive context menu
Profiles = {
[-1] = 0, --Unregistered User
[0] = 1, --Master
[1] = 0, --Operator
[2] = 0, --Vip
[3] = 0, --Registered User
[4] = 0, --Moderator
[5] = 1, --NetFounder
}
--????[ End User Settings ]??????????????????????????????????????????????????????
PM=0
function NewUserConnected(user)
if Profiles[user.iProfile] == 1 then
user:SendData("$UserCommand 1 1 "..rMenu.."\\"..SubMenu.."\\Send File $<%[mynick]> "..SendCmd.." %[line:File Without Extension]|||")
user:SendData("$UserCommand 1 3 "..rMenu.."\\"..SubMenu.."\\List Files $<%[mynick]> "..ListCmd.."|")
end
end
OpConnected = NewUserConnected
function ChatArrival(user, data)
data=string.sub(data,1,-2)
s,e,cmd = string.find(data,"%b<>%s+(%S+)")
data = string.sub(data,string.len(user.sName)+string.len(cmd)+2,-1)
s,e,text = string.find(data,"(%w+)")
if (cmd==SendCmd) then GetItemByName(Nick)
if Profiles[user.iProfile] == 1 then
if cmd and text then
PM=0
GetFile(user,text)
else
local syntaxerr = "Syntax Error\tCommand Syntax= <"..SendCmd.."> "..
" (file extension not required)"
user:SendData(sytaxerr)
end
else
SendToNick(user.sName,"Sorry "..user.sName..", your not allowed use of the "..SendCmd.." command.")
return 1
end
return 1
end
if (cmd==ListCmd) then
if Profiles[user.iProfile] == 1 then
DoList(user)
return 1
else
SendToNick(user.sName,"Sorry "..user.sName..", your not allowed use of the "..ListCmd.." command.")
return 1
end
end
end
function ToArrival(user,data)
if string.sub(data,1,5)== "$To: " then
local s,e,to = string.find(data,"$To:%s+(%S+)%s+From:")
local s,e,cmd = string.find(data,"$<.+>%s+(%S+)%s+")
local s,e,text = string.find(data,"(%w+)|")
if to then
if cmd and cmd==SendCmd then
if Profiles[user.iProfile] == 1 then
GetItemByName(Nick)
if cmd and text then
PM=1
GetFile(user,text,to)
return 1
else
local syntaxerr = "Syntax Error\tCommand Syntax= <"..SendCmd.."> "..
" (file extension not required)"
user:SendPM(Bot,syntaxerr)
return 1
end
end
else
user:SendPM(Bot,"Sorry "..user.sName..", your not allowed use of the "..SendCmd.." command.")
return 1
end
elseif cmd and cmd==ListCmd then
if Profiles[user.iProfile] == 1 then
DoList(user)
return 1
else
user:SendPM(Bot,"Sorry "..user.sName..", your not allowed use of the "..ListCmd.." commands.")
return 1
end
end
end
end
function GetFile(user,text,to)
local f,e = io.open(FilePath..text..".txt", "r" )
if f then
local lines="\r\n\r\n"
for line in io.lines(FilePath..text..".txt") do
lines = lines..line.."\r\n"
end
local sendtime =os.date("%I:%M:%S %p on %B %d %Y ")
local confirm = "Per your request "..user.sName..", File "..text..".txt sent to "..usrnick.sName.." at "..sendtime
SendPmToNick(usrnick.sName, user.sName,lines.."|")
if PM==1 then
user:SendPM(to,confirm)
PM=0
else
user:SendData(Bot,confirm)
end
return 1
else
local errmsg = "The file "..FilePath..text..".txt does not exist, check your settings."
if PM==1 then
user:SendPM(to,errmsg)
PM=0
else
user:SendData(Bot,errmsg)
end
return 1
end
end
function DoList(user)
local art = string.rep("?",75).."\r\n"--??
local header = "\r\n\r\n\t"..art.."\t The following files may be sent in PM by command\r\n"..
"\t<"..SendCmd.."> (file extension not required)\r\n\r\n\t"..art
os.execute("dir "..FilePath.."*.txt /b /o:gn > listfiles.dir")
local texts=""
for line in io.lines("listfiles.dir") do
texts=texts.."\t"..line.."\r\n"
end
user:SendPM(Bot,header..texts.."\r\n\t"..art)
os.remove("listfiles.dir")
return 1
end
Hopefully someone can fix the bug
Thnx you would help me m8,
I will look at it today :D
greetz
This is it....... :D
This is what I'am looking for,
Thnx for the big hint ;)
Great work........
Greetz,