Here is latest version...
For PtokaX 16.10 and newer
Added:
Permission levels to commands
Permission levels to rightclick
Add/remove line with command
Show lines (when added,by who and line) with command
Add/Remove bot from userlist with command
--//--------------------------------------------------------//--
--//-- Chatter Bot -----------------------------------------//--
--//-- Made by C??o?y?? ------------------------------------//--
--//--------------------------------------------------------//--
--//-- ?Sends message to chosen field with time interval? --//--
--//--------------------------------------------------------//--
--//-- Thx to Optimus for helping --------------------------//--
--//-- Added: ----------------------------------------------//--
-- Permission levels to commands ---------------------------//--
-- Permission levels to rightclick -------------------------//--
-- Add/remove line with command ----------------------------//--
-- Show lines (when added,by who and line) with command ----//--
-- Add/Remove bot from userlist with command ---------------//--
------------------------------------------------------------//--
sBot = "????Chatter????" -- Bots name
Where = 2 -- Where you want messages go (2/topic 1/main 0/box under chat)
rBot = 1 -- Should bot be in user list when script start (1/yes 0/no)
StartOn = 1 -- Should bot start on restart (1/yes 0/no)
LineFile = "lines.tbl" -- File where all lines are added
Mins = 1 -- Interval (in minutes) between messages
TopLine = 10 -- How many last lines you want to see
MaxLines = 500 -- Don't set it to high it will give problems
ShowLine = "pm" -- Where it gives u added lines main/pm
UserCommands = 1 -- Add Rightclick commands
zMenu = "?~Chatter~?" -- Rightclick menus name
Version = "1.3"
--//-- Who can use commands --
CanDo = {
[0] = 1, -- Master
[1] = 1, -- Operator
[2] = 0, -- VIPs
[3] = 0, -- Regs
[4] = 1, -- Moderator
[5] = 1, -- Netfounder
}
--//-- Who gets rightclick commands --
Allowed = {
[0] = 1, -- Master
[1] = 1, -- Operator
[2] = 0, -- VIPs
[3] = 0, -- Regs
[4] = 1, -- Moderator
[5] = 1, -- Netfounder
}
Line = {}
sCommands = {}
CmdPrefix = {
["!"]=1,
["?"]=1,
["+"]=1,
}
----------------------------------------------------------------------------------------------
function OnTimer()
local iCount = math.random(table.getn(Line))
if Where==1 then
SendToAll(sBot,"\n\r\n\t"..Line[iCount][2].."\r\n")
elseif Where==2 then
frmHub:SetHubTopic(Line[iCount][2])
elseif Where==0 then
SendToAll("\t"..Line[iCount][2].."\t\t\t\t\t\t\t\t\t\t\t is kicking because:")
end
end
Main = function()
dofile(LineFile)
SetTimer(Mins*60000)
--NewLines = GetLines(table.getn(Line), table.getn(Line)-TopLine)
if rBot == 1 then frmHub:RegBot(sBot) end
if StartOn == 1 then StartTimer() end
end
OpConnected = function(user)
SendCommands(user)
end
sCommands["addline"] = function(user, data)
if CanDo[user.iProfile] == 1 then
local s,e,item = string.find(data, "%b<>%s+%S+%s+(.+)%-(.*)")
if s then
if table.getn(Line) < MaxLines then
table.insert(Line,{user.sName,item,os.date("%x")})
saveTableToFile(LineFile, Line, "Line")
NewLines = GetLines(table.getn(Line), table.getn(Line)-TopLine)
SendToOps(sBot, ""..user.sName.." added line Nr. ["..table.getn(Line).."] *** "..item.." *** to Chatter! ")
else
user:SendMessage(sBot, "*** Database is full, maximum number of Messages is: "..MaxLines)
end
else
user:SendMessage(sBot, "*** Usage: !addline ")
end
end
return 1
end
sCommands["removeline"] = function(user, data)
if CanDo[user.iProfile] == 1 then
local s,e,nr = string.find(data, "%b<>%s+%S+%s+(%d+)")
if s then
if Line[tonumber(nr)] then
table.remove(Line,nr)
saveTableToFile(LineFile, Line, "Line")
NewLines = GetLines(table.getn(Line), table.getn(Line)-TopLine)
SendToOps(sBot, ""..user.sName.." removed Line nr.["..nr.."] from database!")
else
user:SendMessage(sBot, "*** Line nr."..nr.." is not in database!")
end
else
user:SendMessage(sBot, "*** Usage: !removeline nr")
end
end
return 1
end
sCommands["showlines"] = function(user, data)
if CanDo[user.iProfile] == 1 then
local disp = "\r\n\t\t?=========================? "..sBot.." ?=========================?\r\n\r\n"
disp = disp..GetLines(table.getn(Line), 1)
ShowWhere(user, ShowLine, disp.."\r\n\t\t?=========================? "..sBot.." ?=========================?")
end
return 1
end
sCommands["cleanlines"] = function(user, data)
if CanDo[user.iProfile] == 1 then
local howmuch = table.getn(Line)
if howmuch >= MaxLines then
for I = 1,howmuch/2 do table.remove(Line,i) end
saveTableToFile(LineFile, Line, "Line")
user:SendMessage(sBot, "The database is cleaned!")
else
user:SendMessage(sBot, "The database doesn't need to be cleaned!")
end
end
return 1
end
sCommands["chaton"] = function(user,data)
if CanDo[user.iProfile] == 1 then
if Where==0 then
SendToOps(sBot," Started ?? Messages will be shown Under Chat at every "..Mins.." minute/s. Type !chatoff to stop me.")
StartTimer()
elseif Where==1 then
SendToOps(sBot," Started ?? Messages will be shown in Mainchat at every "..Mins.." minute/s. Type !chatoff to stop me.")
StartTimer()
elseif Where==2 then
SendToOps(sBot," Started ?? Messages will be shown in Topic at every "..Mins.." minute/s. Type !chatoff to stop me.")
StartTimer()
end
return 1
end
end
sCommands["chatoff"] = function(user,data)
if CanDo[user.iProfile] == 1 then
SendToOps(sBot," Stopped ?? Type !chaton to start me again.")
StopTimer()
end
return 1
end
sCommands["regbot"] = function(user,data)
if CanDo[user.iProfile] == 1 then
SendToOps(sBot," "..sBot.." added to userlist")
frmHub:RegBot(sBot)
end
return 1
end
sCommands["unregbot"] = function(user,data)
if CanDo[user.iProfile] == 1 then
SendToOps(sBot," "..sBot.." removed from userlist")
frmHub:UnregBot(sBot)
end
return 1
end
GetLines = function(startpos, endpos)
local text = ""
for i = startpos, endpos, -1 do
if Line[i] then
text = text.."\t ["..i.."] "..Line[i][3].." By: "..Line[i][1].." \r\n\t Line: "..Line[i][2].." \r\n"
end
end
return text
end
ChatArrival = function(user, data)
user.SendMessage = user.SendData return GetCommands(user, data)
end
ToArrival = function(user, data)
local s,e,to = string.find(data, "$To: (%S+%s?%S*)%sFrom:")
if to == sBot then
user.SendMessage = user.SendPM return GetCommands(user, data)
end
end
GetCommands = function(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,prefix,cmd=string.find(data, "%b<>%s*(%S)(%S+)")
if prefix and CmdPrefix[prefix] and sCommands[cmd] then
return sCommands[cmd](user, data)
end
end
ShowWhere = function(user, where, msg)
if where == "main" then user:SendData(sBot, msg) elseif where == "pm" then user:SendPM(sBot, msg) end
end
----------------------------------------------------------------------------------------------
SendCommands = function(user)
if UserCommands == 1 then
if user.bUserCommand then
user:SendData("$UserCommand 0 3")
user:SendData("$UserCommand 1 3 "..zMenu.."\\**"..sBot.." v"..Version.."**$<%[mynick]>||")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Start bot$<%[mynick]> !chaton||")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Stop bot$<%[mynick]> !chatoff||")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Add "..sBot.." to userlist$<%[mynick]> !regbot||")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Remove "..sBot.." from userlist$<%[mynick]> !unregbot||")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Show Lines$<%[mynick]> !showlines||")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Add Line$<%[mynick]> !addline %[line:New line] -||")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Delete Line$<%[mynick]> !removeline %[line:Number]||")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Clean DataBase$<%[mynick]> !cleanlines||")
end
end
end
----------------------------------------------
-- load & save Tables
----------------------------------------------
Serialize = function(tTable, sTableName, hFile)
hFile:write(sTableName.." = {\n")
for key,value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Serialize(value,sKey,hFile)
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write(sKey.." = "..sValue)
end hFile:write(",\n")
end hFile:write("}")
end
-----------------------------------------------------------
saveTableToFile = function(file, table, tablename)
local handle = io.open(file,"w")
Serialize(table,tablename,handle)
handle:close()
end
using ptokax 17.08 with chatter bot
got this error
[22:07] Syntax cannot read lines.tbl: No such file or directory
does the script automatically make the lines.tbl ?
or should i manually make it and how ?
QuoteOriginally posted by dkt
using ptokax 17.08 with chatter bot
got this error
[22:07] Syntax cannot read lines.tbl: No such file or directory
does the script automatically make the lines.tbl ?
or should i manually make it and how ?
Yep when u add first line it will create that file =)
Works fine here with 17.08
v1.4
-- Command to set maxlines --
-- Command to set where shows added lines (main/pm) --
-- Command to set time between messages --
-- Command to set where messages will be sent (main/topic/statusbar)
-- Makes new line.tbl if file missing --
-- Some code cleaning --
Chatter v1.4 (http://www.tazman77.demon.nl/Chatter%201.4.rar)
great script :P
QuoteOriginally posted by (-=TrIp-iN-SuN=-)
great script :P
thx :P
QuoteOriginally posted by (-=TrIp-iN-SuN=-)
great script :P
Not great script but very great script :p