just completing a little request on ukknnet board, but its better than i thought
enjoy
-- userlist by bastya_elvtars
-- shows a sorted userlist in PM divided into categories
-- ascii should be updated by somebody who has ascii design skills
-- will be deprecated in lua5 px ;)
-- sure u should edit these if needed
bot="userlist-bot"
command="userlist" -- no leading ! or other prefix plz - supports ! + #
level=2 -- levels are always the following, determining who CAN use the command:
-- 5:only superops
-- 4 ops & above
-- 3 vips & above
-- 2 registered users & above
-- 1 anyone
-- 0 disabled
-- not sure u should edit below without minimal lua knowledge.
users={}
users["reg"]={}
users["su"]={}
users["op"]={}
users["vip"]={}
users["guest"]={}
toins={
[1]=users["op"],
[2]=users["vip"],
[3]=users["reg"],
[0]=users["su"],
[-1]=users["guest"],
}
userlevels={[-1]=1,[0]=5,[1]=4,[2]=3,[3]=2}
function NewUserConnected(user)
if toins[user.iProfile] then
toins[user.iProfile][user.sName]=1
end
end
function Main()
frmHub:RegBot(bot)
end
function UserDisconnected(user)
if toins[user.iProfile] then
toins[user.iProfile][user.sName]=nil
end
end
function userlist()
return ("This Is The Current UserList:\r\n\r\n=======================\r\n=======================\r\nSuperops:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[0]).."--------------------------------------\r\n\r\nOps:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[1]).."--------------------------------------\r\n\r\nVIPs:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[2]).."--------------------------------------\r\n\r\nREGs:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[3]).."--------------------------------------\r\n\r\nGuests:\r\n--------------------------------------\r\n"..
makelistofaddedprofileintable(toins[-1]).."\r\n\r\n=======================\r\n=======================")
end
function makelistofaddedprofileintable(table)
local txt=""
local arr={}
for a,b in table do
tinsert(arr,a)
end
sort(arr)
for u=1,getn(arr) do
txt=txt..arr[u].."\r\n"
end
return txt
end
function DataArrival(user,data)
if userlevels[user.iProfile]>=level then
if strsub(data, 1, 4) == "$To:" then
data=strsub(data,1,strlen(data)-1)
-- is this meant for our bot?
local _,_,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == Bot) then
local _,_,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+[%!%+%#](%S+)")
if cmd==command then
user:SendPM(bot,userlist())
end
elseif strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"%b<>%s+[%!%+%#](%S+)")
if cmd==command then
user:SendPM(bot,userlist())
end
end
end
end
end
OpConnected=NewUserConnected
OpDisconnected=UserDisconnected
this is the error I got today when I tried the script:
Syntax Error: unfinished string;
last token read: `"This Is The Current UserList' at line 117 in string "-- userlist by bastya_elvtars
..."
replace the userlist() function with this one ..
function userlist()
local msg ="This Is The Current UserList:\r\n\r\n"
msg = msg..srtrep(strrep("=", 20).."\r\n", 2).."Superops:>\r\n"
msg = msg..srtrep("-", 37).."\r\n"
msg = msg..makelistofaddedprofileintable(toins[0])
msg = msg..srtrep("-", 37).."\r\n"
msg = msg.."\r\nOps:\r\n"
msg = msg..srtrep("-", 37).."\r\n"
msg = msg..makelistofaddedprofileintable(toins[1])
msg = msg..srtrep("-", 37).."\r\n"
msg = msg.."\r\nVIPs:\r\n
msg = msg..srtrep("-", 37).."\r\n"
msg = msg..makelistofaddedprofileintable(toins[2])
msg = msg..srtrep("-", 37).."\r\n"
msg = msg.."\r\nREGs:\r\n"
msg = msg..srtrep("-", 37).."\r\n"
msg = msg..makelistofaddedprofileintable(toins[3])
msg = msg..srtrep("-", 37).."\r\n"
msg = msg.."\r\nGuests:\r\n"
msg = msg..srtrep("-", 37).."\r\n"
msg = msg..makelistofaddedprofileintable(toins[-1]).."\r\n"
msg = msg..srtrep(strrep("=", 20).."\r\n", 2).."\r\n"
return msg
end
//completely untested//