Author Topic: Command Px  (Read 709 times)

0 Members and 1 Guest are viewing this topic.

Offline Massi

  • Junior Member
  • **
  • Posts: 22
  • Karma: +3/-0
Command Px
« on: 11 June, 2021, 10:30:03 »
Please, convert in Lua 5.3.4 for Ptokax 0.5.2.2 thanks  :)


Code: [Select]
--[[ PxCommands 1.1f Lite Ed. LUA 5.1 [Strict] [API 2] By Mutor 03/07/06 40% less calories than the standard edition :P -Sends inbuilt PtokaX user commands (per profile permissions) -Allows for default custom / commands -Allows for raw commands for ops +Changes from 1.1 Standard Edition 08/08/07 -Removed LUA version checking, converted for LUA 5.1 only. -Removed PxUtilities dependency and associated functions. +Profile commands sent in specific [editable] order. +Added profiles 4 - 6 for use with AIO scripts ~Changed timer function, garbage collection. ~Changed status message format and method ~Moved config table to a local variable. +Changes from 1.1 Lite Ed. 08/08/07 -Removed Bot registration & related info. -Removed most anything not required for basic function +All commands written to external files, one per profile. +File read and sent to user at connect +Command functions Default, Raw & Prof nil after 1st run +This method offers a savings of ~20Kb memory usage +Changes from 1.1b Lite Ed.. 09/14/07 ~Rewritten for the new PtokaX API [0.3.06d +] +Changes from 1.1c Lite Ed.. 11/17/07 -Removed Core.GetUserAllData in UserConnected, no longer req'd. +Added user message to data string *Optimizations suggestions by PPK: ~Changed SendToNick to SendToUser, all data sent together +Changes from 1.1d Lite Ed.. 04/26/08 +Added custom user commands. +Changes from 1.1f Lite Ed.. 01/11/09 ~Update for profile permission changes in PxLua API [version 0.4.1.2 and later] ]]-- local CmdCfg = { --Command Menu Name ["" = Hub Name] Menu = "", --Bot Name ["" = Hub Bot] Bot = "", -- Clear the Hub/User menu first, before new commands set is sent at login? true/false -- Avoids duplicate menus. ***If enabled, load this script before other command scripts ClearMenu = true, --Send raw commands to operators? true/false SendRaw = true, } -- Custom profile level for Custom Commands local CustomLevel = {[-1] = 1,[0] = 5,[1] = 4,[2] = 3,[3] = 2,} -- Add your own custom commands -- Set first value as minimum profile level from CustomLevel table, second as typical User Command, ending in || CustomCmds = { --{#,"$UserCommand 1 1 Menu\\SubMenu\\Command Description$<%[mynick]> +command %[line:arg]||"} {1,"$UserCommand 1 3 Menu\\SubMenu\\Common Knowledge$<%[mynick]> Mutor is dead sexy!||"}, } OnStartup = function() Set=function(a,v,h)--(arg,val,hub) if a == "" then if h then return SetMan.GetString(v) else return v end else return a end end CmdCfg.Bot = Set(CmdCfg.Bot,21,true) CmdCfg.Menu = Set(CmdCfg.Menu,0,true) CmdCfg.Path = Core.GetPtokaXPath().."scripts/" local t,x = ProfMan.GetProfiles(),DefaultCmds(-1) for i,v in ipairs(t) do local p = i-1 local Commands = DefaultCmds(p) if CmdCfg.SendRaw and ProfMan.GetProfile(p).tProfilePermissions.bIsOP then local Raw = RawCmds(p) if Raw then Commands = Commands..Raw end end Commands = Commands..ProfCmds(p) local f,e = io.open(CmdCfg.Path..p..".uc","wb") f:write("return "..string.format("%q",Commands)) f:flush() f:close() end local f,e = io.open(CmdCfg.Path.."-1.uc","wb") f:write("return "..string.format("%q",x)) f:flush() f:close() DefaultCmds,RawCmds,ProfCmds = nil,nil,nil end UserConnected = function(user) if loadfile(CmdCfg.Path..tostring(user.iProfile)..".uc") then local x,count = dofile(CmdCfg.Path..tostring(user.iProfile)..".uc") if x then _,count = x:gsub("||","%1") end if x then _,count = x:gsub("UserCommand","%1") end if count and count > 0 then if CmdCfg.ClearMenu then x = "$UserCommand 255 3 "..CmdCfg.Menu.."||"..x end local HubApp,HubVer,Prof = "PtokaX", Core.Version,"Unregistered User" if user.iProfile ~= -1 then Prof = ProfMan.GetProfile(user.iProfile).sProfileName end x = x.."<"..CmdCfg.Bot.."> Welcome "..user.sNick..", [ ".. tostring(count).." ] "..Prof.."'s "..HubApp.." "..HubVer.." commands enabled. Right ".. "click hub tab or user list for menu.|" local lvl = CustomLevel[user.iProfile] for i,v in ipairs(CustomCmds) do if lvl and lvl >= v[1] then x = x..v[2] end end Core.SendToUser(user,x) end end end RegConnected,OpConnected = UserConnected,UserConnected DefaultCmds = function(idx) local str,pfx,menu = "",SetMan.GetString(29):sub(1,1) or "+",CmdCfg.Menu --//-- Add your custom/default commands here --//-- Index = { --//-- [0] = {[-1]=1,[0]=1,[1]=1,[2]=1,[3]=1}, --//-- [#] = {"command", "args", "Command Description", "Submenu", *Context}, --//-- }, --//-- --//-- Key [0] contains idx profiles, use =1 to enable that profile, =0 to disable --//-- *Context --//-- 1=Hub Menu 2=User Menu 3=Hub/User Menu 4 = File[Search] 5 = Hub/File 6 = User/File 7 = Hub/User/File local Default = { [1] = { [0] = {[-1]=true,[0]=true,[1]=true,[2]=true,[3]=1}, [1] = {"help", "", "Get Command Help", "General",3,}, }, [2] = { [0] = {[-1]=false,[0]=true,[1]=true,[2]=true,[3]=true,}, [1] = {"passwd", " %[line:New Password]", "Change Your Password", "General",3}, }, [3] = { [0] = {[-1]=true,[0]=true,[1]=true,[2]=true,[3]=true,}, [1] = {"myip", "", "Display Your IP Address", "General",3}, }, [4] = { [0] = {[-1]=false,[0]=true,[1]=true,[2]=true,[3]=true,}, [1] = {"me", " %[line:Say What?]", "Speak In The Third Person", "General",3}, }, [5] = { [0] = {[-1]=true,[0]=true,[1]=true,[2]=true,[3]=true,}, [1] = {"stats", "", "Get Hub Statistics", "General",3}, }, [6] = { [0] = {[-1]=true,[0]=true,[1]=true,[2]=true,[3]=true,}, [1] = {"memstats", "", "Get Hub Memory Statistics", "General",3}, }, } for i,v in ipairs(Default) do if v[0][idx]then for a,b in ipairs(v) do if a > 0 then str = str.."$UserCommand 1 "..b[5].." "..menu.."\\"..b[4].."\\".. b[3].." $<%[mynick]> "..pfx..b[1]..b[2].."||" end end end end return str end --There is not a whole lot of need for this but I was bored --Note: Badly formed raw commands will disconnect your from hub --These commands offered as examples, check your hub settings before use RawCmds = function(idx) local str,menu,rda,srda = "",CmdCfg.Menu, SetMan.GetString(6) or " %[line:Redirect To? (Address:Port)]", SetMan.GetString(12) or " %[line:Redirect Bad Share To? (Address:Port)]" local RawCommands = { [1] = { [1] = {"$$To:"," %[nick] From: %[mynick] $<%[mynick]> %[line:Message (Select Nicks First)]", "Selective Private Message","Messages",2}, }, [2] = { [1] = {"$$OpForceMove", " $Who:%[line:Victim Nick]$Where:"..rda.. "$Msg:%[line:Reason]", "Redirect To Default", "User Admin",1}, [2] = {"$$OpForceMove", " $Who:%[nick]$Where:"..rda.. "$Msg:%[line:Reason]", "Redirect To Default", "User Admin",2}, [3] = {"$$OpForceMove", " $Who:%[line:Victim Nick]$Where:"..srda.. "$Msg:%[line:Reason]", "Redirect Bad Share", "User Admin",1}, [4] = {"$$OpForceMove", " $Who:%[nick]$Where:"..srda.. "$Msg:%[line:Reason]", "Redirect Bad Share", "User Admin",2}, }, [3] = { [1] = {"$$Quit"," %[mynick]","Disconnect From Hub","Hub Admin",2}, }, [4] = { [1] = {"$$Close"," %[line:Close Who?]","Close User","User Admin",1}, [2] = {"$$Close"," %[nick]","Close User","User Admin",2}, }, [5] = { [1] = {"$$To:"," %[line:Nick] From: %[mynick] $<%[mynick]> You are being kicked.||<%[mynick]> is kicking %[line:Nick]||$Kick %[line:Nick]","Kick User","Raw Cmds",1}, [2] = {"$$To:"," %[nick] From: %[mynick] $<%[mynick]> You are being kicked.||<%[mynick]> is kicking %[nick]||$Kick %[nick]","Kick User","Raw Cmds",2}, }, } for i,v in ipairs(RawCommands) do for a,b in ipairs(v) do str = str.."$UserCommand 1 "..b[5].." "..menu.."\\".. b[4].."\\"..b[3]..b[1]..b[2].."||" end end return str end ProfCmds = function(idx) local str,pfx,menu,perms = "",SetMan.GetString(29):sub(1,1) or "+",CmdCfg.Menu,ProfMan.GetProfile(idx).tProfilePermissions --Format change here, don't edit the first [1] key/value pair of each command or script will fail -- You may however, edit entries after [1] if you'd like local Commands = { [1] = { [1] = {bTempUnban = 0}, [2] = {"tempunban", " %[line:Nick Or IP To unban]", "Temp Unban Nick/IP", "Ban Admin",3}, }, [2] = { [1] = {bGetInfo = 0}, [2] = {"getinfo", " %[nick]", "Get User Info", "User Info",2}, }, [3] = { [1] = {bGag = 0}, [2] = {"gag", " %[line:Nick To Gag]", "The User Can't Post To Mainchat Anymore", "User Admin",1}, [3] = {"gag", " %[nick]", "The User Can't Post To Mainchat Anymore", "User Admin",2}, [4] = {"ungag", " %[line:Nick To Ungag]", "The User Can Post To Mainchat Again", "User Admin",1}, [5] = {"ungag", " %[nick]", "The User Can Post To Mainchat Again", "User Admin",2} }, [4] = { [1] = {bGetBans = 0}, [2] = {"getbans", "", "Display Bans", "Ban Admin",3}, [3] = {"getpermbans", "", "Display Permanent Bans", "Ban Admin",3}, [4] = {"gettempbans", "", "Display Temporary Bans", "Ban Admin",3}, [5] = {"checknickban", " %[line:Check This Nick]", "Check Nick For Ban", "Ban Admin",3}, [6] = {"checkipban", " %[line:Check This IP]", "Check IP For Ban", "Ban Admin",3}, }, [5] = { [1] = {bMassMsg = 0}, [2] = {"massmsg", " %[line:Mass Message For Users]", "Send A Private Message To All Users", "Messages",3}, [3] = {"opmassmsg", " %[line:Mass Message For Ops]", "Send A Private Message To All Ops", "Messages",3}, }, [6] = { [1] = {bClearRangeTempBans = 0}, [2] = {"clrrangetempbans", "", "Clear Temporary Range Bans", "Range Ban Admin",3}, }, [7] = { [1] = {bRangeUnban = 0}, [2] = {"rangeunban", " %[line:Start Of IP Range] %[line:End Of IP Range]", "Unban An IP Range", "Range Ban Admin",3}, }, [8] = { [1] = {bTopic = 0}, [2] = {"topic", " %[line:Topic (off = Clear Topic)]", "Set/Change/Clear Hub Topic", "Hub Admin",3}, }, [9] = {--m=Mins, h=Hours, d=Days, w=Weeks, M=Months, Y=Years. [1] = {bTempBan = 0}, [2] = {"tempban", " %[nick] %[line:Time To Ban] %[line:Reason For Ban]", "Temp Ban User", "Ban Admin",2}, [3] = {"nicktempban", " %[nick] %[line:Time To Ban] %[line:Reason For Ban]", "Temp Ban Nick", "Ban Admin",2}, [4] = {"tempbanip", " %[ip] %[line:Time To Ban] %[line:Reason For Ban]", "Temp Ban IP", "Ban Admin",2}, [5] = {"fulltempban", " %[nick] %[line:Time To Ban] %[line:Reason For Ban]", "Full Temp Ban Nick", "Ban Admin",2}, [6] = {"fulltempbanip", " %[ip] %[line:Time To Ban] %[line:Reason For Ban]", "Full Temp Ban IP", "Ban Admin",2}, }, [10] = { [1] = {bKick = 0}, [2] = {"$$Kick", " %[line:Nick To Kick]", "Kick User", "User Admin",1}, [3] = {"$$Kick", " %[nick]", "Kick User", "User Admin",2}, }, [11] = { [1] = {bRestartScripts = 0}, [2] = {"getscripts", "", "Display Current Script & Status", "Hub Admin",3}, [3] = {"restartscripts", "", "Restart All Scripts", "Hub Admin",3}, [4] = {"startscript", " %[line:Script Filename]", "Start Specified Script", "Hub Admin",3}, [5] = {"stopscript", " %[line:Script Filename]", "Stop Specified Script", "Hub Admin",3}, [6] = {"restartscript", " %[line:Script Filename]", "Restart Specified Script", "Hub Admin",3}, }, [12] = { [1] = {bRangeTempBan = 0}, [2] = {"rangetempban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Time For Ban] %[line:Reason For Ban]", "Temporary Ban An IP Range", "Range Ban Admin",3}, [3] = {"fullrangetempban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Time For Ban] %[line:Reason For Ban]", "Full Temporary Ban An IP Range", "Range Ban Admin",3}, }, [13] = { [1] = {bTempOP = 0}, [2] = {"op", " %[line:Nick]", "Grant Temporary Op Status To User For One Session", "Registration",1}, [3] = {"op", " %[nick]", "Give Temporary Op Status To User For One Session", "Registration",2}, }, [14] = { [1] = {bAddRegUser = 0}, [2] = {"addreguser", " %[line: Nick To Register] %[line:Password For Nick] %[line:Profile (Reg/VIP/Operator/Master)]", "Register A User", "Registration",1}, [3] = {"addreguser", " %[nick] %[line:Password For Nick] %[line:Profile (Reg/VIP/Operator/Master)]", "Register A User", "Registration",2}, }, [15] = { [1] = {bUnban = 0}, [2] = {"unban", " %[line:Nick or IP to Unban]", "Unban Nick/IP", "Ban Admin",3}, [3] = {"permunban", " %[line:Nick or IP to Unban]", "Perm Unban Nick/IP", "Ban Admin",3}, }, [16] = { [1] = {bClrPermBan = 0}, [2] = {"clrpermbans", "", "Clear Permanent Bans", "Ban Admin",3}, }, [17] = { [1] = {bRangeTempUnban = 0}, [2] = {"rangetempunban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Time For Ban] %[line:Reason For Ban]", "Unban Temporary IP Range Ban", "Range Ban Admin",3}, }, [18] = { [1] = {bDelRegUser = 0}, [2] = {"delreguser", " %[line:Nick To Delete]", "Delete A User From Registry", "Registration",1}, [3] = {"delreguser", " %[nick]", "Delete A User From Registry", "Registration",2}, }, [19] = { [1] = {bClearRangePermBans = 0}, [2] = {"clrrangepermbans", "", "Clear Permanent Range Bans", "Range Ban Admin",3}, }, [20] = { [1] = {bRefreshTxt = 0}, [2] = {"reloadtxt", "", "Reload Textfiles", "Hub Admin",3}, }, [21] = { [1] = {bRangeBan = 0}, [2] = {"rangeban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Reason For Ban]", "Permanently Ban An IP Range", "Range Ban Admin",3}, [3] = {"fullrangeban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Reason For Ban]", "Permanently Ban An IP Range", "Range Ban Admin",3}, }, [22] = { [1] = {bGetRangeBans = 0}, [2] = {"getrangebans", "", "Display Banned IP Ranges", "Range Ban Admin",3}, [3] = {"getrangepermbans", "", "Display Permanently Banned IP Ranges", "Range Ban Admin",3}, [4] = {"getrangetempbans", "", "Display Temporarily Banned IP Ranges", "Range Ban Admin",3}, [5] = {"checkrangeban", " %[line:Start Of IP Range] %[line:End Of IP Range]", "Check Bans For This IP Range", "Range Ban Admin",3}, }, [23] = { [1] = {bDrop = 0}, [2] = {"drop", " %[line:Nick To Drop] %[line:Reason For Drop]", "Silent Kick With Tempban", "User Admin",1}, [3] = {"drop", " %[nick] %[line:Reason For Drop]", "Silent Kick With Tempban", "User Admin",2}, }, [24] = { [1] = {bBan = 0}, [2] = {"ban", " %[nick] %[line:Reason For Ban]", "Ban By Nickname", "User Admin",1}, [3] = {"ban", " %[line:Nick To Ban] %[line:Reason For Ban]", "Ban By Nickname", "User Admin",2}, [4] = {"nickban", " %[line:Nick To Ban] %[line:Reason For Ban]", "Ban Nickname", "User Admin",1}, [5] = {"nickban", " %[nick] %[line:Reason For Ban]", "Ban Nickname", "User Admin",2}, [6] = {"banip", " %[line:Ban This IP] %[line:Reason For Ban]", "Ban IP Address", "User Admin",1}, [7] = {"banip", " %[ip] %[line:Reason For Ban]", "Ban IP Address", "User Admin",2}, [8] = {"fullbanip"," %[line:Ban This IP] %[line:Reason For Ban]", "FullBan IP Address", "User Admin",1}, [9] = {"fullbanip"," %[ip] %[line:Reason For Ban]", "FullBan IP Address", "User Admin",2}, }, [25] = { [1] = {bRestartHub = 0}, [2] = {"restart", "", "Restart The Hub", "Hub Admin",3}, }, [26] = { [1] = {bClrTempBan = 0}, [2] = {"clrtempbans", "", "Clear Temporary Bans", "Ban Admin",3}, }, } for i,v in ipairs(Commands) do local t = {} for key,val in pairs(v[1]) do if perms[key] then t = v end end if next(t) then for a,b in ipairs(t) do if a > 1 then local uc,pre,p = "$UserCommand 1 "," $<%[mynick]> "..pfx,"||" if i == 10 then pre = "" end str = str..uc..b[5].." "..menu.."\\"..b[4].."\\"..b[3]..pre..b[1]..b[2]..p end end end end return str end
Best Regards,
Massimiliano
« Last Edit: 11 June, 2021, 12:46:14 by Massi »
¤ .:::[DC++ Community].:::.[Hobby, support, fun and passion]:::. ¤

PtokaX forum

Command Px
« on: 11 June, 2021, 10:30:03 »

Offline Cêñoßy†ê

  • Scripter
  • Triple Ace
  • ******
  • Posts: 201
  • Karma: +34/-3
  • ¤-=[Kñigh†VisioÑ.::.Ñe†WorX]=-¤
    • ¤-=[Kñigh†VisioÑ.::.Ñe†WorX]=-¤
Re: Command Px
« Reply #1 on: 29 June, 2021, 16:08:39 »
Code: [Select]
--[[

PxCommands 1.1g Lite Ed. LUA 5.1 [Strict] [API 2]

By Mutor 03/07/06

40% less calories than the standard edition :P

-Sends inbuilt PtokaX user commands (per profile permissions)
-Allows for default custom / commands
-Allows for raw commands for ops

+Changes from 1.1 Standard Edition 08/08/07
-Removed LUA version checking, converted for LUA 5.1 only.
-Removed PxUtilities dependency and associated functions.
+Profile commands sent in specific [editable] order.
+Added profiles 4 - 6 for use with AIO scripts
~Changed timer function, garbage collection.
~Changed status message format and method
~Moved config table to a local variable.

+Changes from 1.1 Lite Ed. 08/08/07
-Removed Bot registration & related info.
-Removed most anything not required for basic function
+All commands written to external files, one per profile.
+File read and sent to user at connect
+Command functions Default, Raw & Prof nil after 1st run
+This method offers a savings of ~20Kb memory usage

+Changes from 1.1b Lite Ed.. 09/14/07
~Rewritten for the new PtokaX API [0.3.06d +]

+Changes from 1.1c Lite Ed.. 11/17/07
-Removed Core.GetUserAllData in UserConnected, no longer req'd.
+Added user message to data string

*Optimizations suggestions by PPK:
~Changed SendToNick to SendToUser, all data sent together

+Changes from 1.1d Lite Ed.. 04/26/08
+Added custom user commands.


+Changes from 1.1f Lite Ed.. 01/11/09
~Update for profile permission changes in PxLua API [version 0.4.1.2 and later]

+Changes from 1.1f Lite Ed.. 02/13/10
~Changed Custom Commands, Custom Level to full profile table, per command. requested by JiMMy

]]--


local CmdCfg = {
--Command Menu Name ["" = Hub Name]
Menu = "",
--Bot Name ["" = Hub Bot]
Bot = "",
-- Clear the Hub/User menu first, before new commands set is sent at login?  true/false
-- Avoids duplicate menus. ***If enabled, load this script before other command scripts
ClearMenu = true,
--Send raw commands to operators? true/false
SendRaw = true,
}
-- Add your own custom commands
-- Set first value as table of profiles, second as typical User Command, ending in &#124;|
CustomCmds = {
--{{[-1]=false,[0]=true,[1]=true,[2]=true,[3]=true},"$UserCommand 1 1 Menu\\SubMenu\\Command Description$<%[mynick]> +command %[line:arg]&#124;|"}
{{[-1]=true,[0]=true,[1]=true,[2]=true,[3]=true},"$UserCommand 1 3 Menu\\SubMenu\\Common Knowledge$<%[mynick]> Mutor is dead sexy!&#124;|"},
}

OnStartup = function()
Set=function(a,v,h)--(arg,val,hub)
if a == "" then if h then return SetMan.GetString(v) else return v end else return a end
end
CmdCfg.Bot = Set(CmdCfg.Bot,21,true) CmdCfg.Menu = Set(CmdCfg.Menu,0,true)
CmdCfg.Path = Core.GetPtokaXPath().."scripts/"
local t,x = ProfMan.GetProfiles(),DefaultCmds(-1)
for i,v in ipairs(t) do
local p = i-1
local Commands = DefaultCmds(p)
if CmdCfg.SendRaw and ProfMan.GetProfile(p).tProfilePermissions.bIsOP then
local Raw = RawCmds(p)
if Raw then Commands = Commands..Raw end
end
Commands = Commands..ProfCmds(p)
local f,e = io.open(CmdCfg.Path..p..".uc","wb")
f:write("return "..string.format("%q",Commands)) f:flush() f:close()
end
local f,e = io.open(CmdCfg.Path.."-1.uc","wb")
f:write("return "..string.format("%q",x)) f:flush() f:close()
DefaultCmds,RawCmds,ProfCmds = nil,nil,nil
end

UserConnected = function(user)
if loadfile(CmdCfg.Path..tostring(user.iProfile)..".uc") then
local x,count = dofile(CmdCfg.Path..tostring(user.iProfile)..".uc")
if x then _,count = x:gsub("&#124;|","%1") end
if x then _,count = x:gsub("UserCommand","%1") end
if count and count > 0 then
if CmdCfg.ClearMenu then x = "$UserCommand 255 3 "..CmdCfg.Menu.."&#124;|"..x end
local HubApp,HubVer,Prof = "PtokaX", Core.Version,"Unregistered User"
if user.iProfile ~= -1 then Prof = ProfMan.GetProfile(user.iProfile).sProfileName end
x = x.."<"..CmdCfg.Bot.."> Welcome "..user.sNick..", [ "..
tostring(count).." ] "..Prof.."'s "..HubApp.." "..HubVer.." commands enabled. Right "..
"click hub tab or user list for menu.|"
for i,v in ipairs(CustomCmds) do
if v[1][user.iProfile] then x = x..v[2] end
end
Core.SendToUser(user,x)
end
end
end
RegConnected,OpConnected = UserConnected,UserConnected

DefaultCmds = function(idx)
local str,pfx,menu = "",SetMan.GetString(29):sub(1,1) or "+",CmdCfg.Menu
--//-- Add your custom/default commands here
--//-- Index = {
--//--   [0] = {[-1]=1,[0]=1,[1]=1,[2]=1,[3]=1},
--//-- [#] = {"command", "args", "Command Description", "Submenu", *Context},
--//--   },
--//--
--//-- Key [0] contains idx profiles, use =1 to enable that profile, =0 to disable
--//-- *Context
--//-- 1=Hub Menu 2=User Menu 3=Hub/User Menu 4 = File[Search] 5 = Hub/File 6 = User/File 7 = Hub/User/File
local Default = {
[1] = {
[0] = {[-1]=true,[0]=true,[1]=true,[2]=true,[3]=1},
[1] = {"help", "", "Get Command Help", "General",3,},
},
[2] = {
[0] = {[-1]=false,[0]=true,[1]=true,[2]=true,[3]=true,},
[1] = {"passwd", " %[line:New Password]", "Change Your Password", "General",3},
},
[3] = {
[0] = {[-1]=true,[0]=true,[1]=true,[2]=true,[3]=true,},
[1] = {"myip", "", "Display Your IP Address", "General",3},
},
[4] = {
[0] = {[-1]=false,[0]=true,[1]=true,[2]=true,[3]=true,},
[1] = {"me", " %[line:Say What?]", "Speak In The Third Person", "General",3},
},
[5] = {
[0] = {[-1]=true,[0]=true,[1]=true,[2]=true,[3]=true,},
[1] = {"stats", "", "Get Hub Statistics", "General",3},
},
[6] = {
[0] = {[-1]=true,[0]=true,[1]=true,[2]=true,[3]=true,},
[1] = {"memstats", "", "Get Hub Memory Statistics", "General",3},
},
}
for i,v in ipairs(Default) do
if v[0][idx]then
for a,b in ipairs(v) do
if a > 0 then
str = str.."$UserCommand 1 "..b[5].." "..menu.."\\"..b[4].."\\"..
b[3].." $<%[mynick]> "..pfx..b[1]..b[2].."&#124;|"
end
end
end
end
return str
end

--There is not a whole lot of need for this but I was bored
--Note: Badly formed raw commands will disconnect you from hub
--These commands offered as examples, check your hub settings before use
RawCmds = function(idx)
local str,menu,rda,srda = "",CmdCfg.Menu,
SetMan.GetString(6) or " %[line:Redirect To? (Address:Port)]",
SetMan.GetString(12) or " %[line:Redirect Bad Share To? (Address:Port)]"
local RawCommands = {
[1] = {
[1] = {"$$To:"," %[nick] From: %[mynick] $<%[mynick]> %[line:Message (Select Nicks First)]",
"Selective Private Message","Messages",2},
},
[2] = {
[1] = {"$$OpForceMove", " $Who:%[line:Victim Nick]$Where:"..rda..
"$Msg:%[line:Reason]", "Redirect To Default", "User Admin",1},
[2] = {"$$OpForceMove", " $Who:%[nick]$Where:"..rda..
"$Msg:%[line:Reason]", "Redirect To Default", "User Admin",2},
[3] = {"$$OpForceMove", " $Who:%[line:Victim Nick]$Where:"..srda..
"$Msg:%[line:Reason]", "Redirect Bad Share", "User Admin",1},
[4] = {"$$OpForceMove", " $Who:%[nick]$Where:"..srda..
"$Msg:%[line:Reason]", "Redirect Bad Share", "User Admin",2},
},
[3] = {
[1] = {"$$Quit"," %[mynick]","Disconnect From Hub","Hub Admin",2},
},
[4] = {
[1] = {"$$Close"," %[line:Close Who?]","Close User","User Admin",1},
[2] = {"$$Close"," %[nick]","Close User","User Admin",2},
},
[5] = {
[1] = {"$$To:"," %[line:Nick] From: %[mynick] $<%[mynick]> You are being kicked.&#124;&#124;<%[mynick]> is kicking %[line:Nick]&#124;&#124;$Kick %[line:Nick]","Kick User","Raw Cmds",1},
[2] = {"$$To:"," %[nick] From: %[mynick] $<%[mynick]> You are being kicked.&#124;&#124;<%[mynick]> is kicking %[nick]&#124;&#124;$Kick %[nick]","Kick User","Raw Cmds",2},
},
}
for i,v in ipairs(RawCommands) do
for a,b in ipairs(v) do
str = str.."$UserCommand 1 "..b[5].." "..menu.."\\"..
b[4].."\\"..b[3]..b[1]..b[2].."&#124;|"
end
end
return str
end

ProfCmds = function(idx)
local str,pfx,menu,perms = "",SetMan.GetString(29):sub(1,1) or "+",CmdCfg.Menu,ProfMan.GetProfile(idx).tProfilePermissions
--Format change here, don't edit the first [1] key/value pair of each command or script will fail
-- You may however, edit entries after [1] if you'd like
local Commands = {
[1] = {
[1] = {bTempUnban = 0},
[2] = {"tempunban", " %[line:Nick Or IP To unban]", "Temp Unban Nick/IP", "Ban Admin",3},
},
[2] = {
[1] = {bGetInfo = 0},
[2] = {"getinfo", " %[nick]", "Get User Info", "User Info",2},
},
[3] = {
[1] = {bGag = 0},
[2] = {"gag", " %[line:Nick To Gag]", "The User Can't Post To Mainchat Anymore", "User Admin",1},
[3] = {"gag", " %[nick]", "The User Can't Post To Mainchat Anymore", "User Admin",2},
[4] = {"ungag", " %[line:Nick To Ungag]", "The User Can Post To Mainchat Again", "User Admin",1},
[5] = {"ungag", " %[nick]", "The User Can Post To Mainchat Again", "User Admin",2}
},
[4] = {
[1] = {bGetBans = 0},
[2] = {"getbans", "", "Display Bans", "Ban Admin",3},
[3] = {"getpermbans", "", "Display Permanent Bans", "Ban Admin",3},
[4] = {"gettempbans", "", "Display Temporary Bans", "Ban Admin",3},
[5] = {"checknickban", " %[line:Check This Nick]", "Check Nick For Ban", "Ban Admin",3},
[6] = {"checkipban", " %[line:Check This IP]", "Check IP For Ban", "Ban Admin",3},
},
[5] = {
[1] = {bMassMsg = 0},
[2] = {"massmsg", " %[line:Mass Message For Users]", "Send A Private Message To All Users", "Messages",3},
[3] = {"opmassmsg", " %[line:Mass Message For Ops]", "Send A Private Message To All Ops", "Messages",3},
},
[6] = {
[1] = {bClearRangeTempBans = 0},
[2] = {"clrrangetempbans", "", "Clear Temporary Range Bans", "Range Ban Admin",3},
},
[7] = {
[1] = {bRangeUnban = 0},
[2] = {"rangeunban", " %[line:Start Of IP Range] %[line:End Of IP Range]", "Unban An IP Range", "Range Ban Admin",3},
},
[8] = {
[1] = {bTopic = 0},
[2] = {"topic", " %[line:Topic (off = Clear Topic)]", "Set/Change/Clear Hub Topic", "Hub Admin",3},
},
[9] = {--m=Mins, h=Hours, d=Days, w=Weeks, M=Months, Y=Years.
[1] = {bTempBan = 0},
[2] = {"tempban", " %[nick] %[line:Time To Ban] %[line:Reason For Ban]", "Temp Ban User", "Ban Admin",2},
[3] = {"nicktempban", " %[nick] %[line:Time To Ban] %[line:Reason For Ban]", "Temp Ban Nick", "Ban Admin",2},
[4] = {"tempbanip", " %[ip] %[line:Time To Ban] %[line:Reason For Ban]", "Temp Ban IP", "Ban Admin",2},
[5] = {"fulltempban", " %[nick] %[line:Time To Ban] %[line:Reason For Ban]", "Full Temp Ban Nick", "Ban Admin",2},
[6] = {"fulltempbanip", " %[ip] %[line:Time To Ban] %[line:Reason For Ban]", "Full Temp Ban IP", "Ban Admin",2},
},
[10] = {
[1] = {bKick = 0},
[2] = {"$$Kick", " %[line:Nick To Kick]", "Kick User", "User Admin",1},
[3] = {"$$Kick", " %[nick]", "Kick User", "User Admin",2},
},
[11] = {
[1] = {bRestartScripts = 0},
[2] = {"getscripts", "", "Display Current Script & Status", "Hub Admin",3},
[3] = {"restartscripts", "", "Restart All Scripts", "Hub Admin",3},
[4] = {"startscript", " %[line:Script Filename]", "Start Specified Script", "Hub Admin",3},
[5] = {"stopscript", " %[line:Script Filename]", "Stop Specified Script", "Hub Admin",3},
[6] = {"restartscript", " %[line:Script Filename]", "Restart Specified Script", "Hub Admin",3},
},
[12] = {
[1] = {bRangeTempBan = 0},
[2] = {"rangetempban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Time For Ban] %[line:Reason For Ban]", "Temporary Ban An IP Range", "Range Ban Admin",3},
[3] = {"fullrangetempban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Time For Ban] %[line:Reason For Ban]", "Full Temporary Ban An IP Range", "Range Ban Admin",3},
},
[13] = {
[1] = {bTempOP = 0},
[2] = {"op", " %[line:Nick]", "Grant Temporary Op Status To User For One Session", "Registration",1},
[3] = {"op", " %[nick]", "Give Temporary Op Status To User For One Session", "Registration",2},
},
[14] = {
[1] = {bAddRegUser = 0},
[2] = {"addreguser", " %[line: Nick To Register] %[line:Password For Nick] %[line:Profile (Reg/VIP/Operator/Master)]", "Register A User", "Registration",1},
[3] = {"addreguser", " %[nick] %[line:Password For Nick] %[line:Profile (Reg/VIP/Operator/Master)]", "Register A User", "Registration",2},
},
[15] = {
[1] = {bUnban = 0},
[2] = {"unban", " %[line:Nick or IP to Unban]", "Unban Nick/IP", "Ban Admin",3},
[3] = {"permunban", " %[line:Nick or IP to Unban]", "Perm Unban Nick/IP", "Ban Admin",3},
},
[16] = {
[1] = {bClrPermBan = 0},
[2] = {"clrpermbans", "", "Clear Permanent Bans", "Ban Admin",3},
},
[17] = {
[1] = {bRangeTempUnban = 0},
[2] = {"rangetempunban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Time For Ban] %[line:Reason For Ban]", "Unban Temporary IP Range Ban", "Range Ban Admin",3},
},
[18] = {
[1] = {bDelRegUser = 0},
[2] = {"delreguser", " %[line:Nick To Delete]", "Delete A User From Registry", "Registration",1},
[3] = {"delreguser", " %[nick]", "Delete A User From Registry", "Registration",2},
},
[19] = {
[1] = {bClearRangePermBans = 0},
[2] = {"clrrangepermbans", "", "Clear Permanent Range Bans", "Range Ban Admin",3},
},
[20] = {
[1] = {bRefreshTxt = 0},
[2] = {"reloadtxt", "", "Reload Textfiles", "Hub Admin",3},
},
[21] = {
[1] = {bRangeBan = 0},
[2] = {"rangeban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Reason For Ban]", "Permanently Ban An IP Range", "Range Ban Admin",3},
[3] = {"fullrangeban", " %[line:Start Of IP Range] %[line:End Of IP Range] %[line:Reason For Ban]", "Permanently Ban An IP Range", "Range Ban Admin",3},
},
[22] = {
[1] = {bGetRangeBans = 0},
[2] = {"getrangebans", "", "Display Banned IP Ranges", "Range Ban Admin",3},
[3] = {"getrangepermbans", "", "Display Permanently Banned IP Ranges", "Range Ban Admin",3},
[4] = {"getrangetempbans", "", "Display Temporarily Banned IP Ranges", "Range Ban Admin",3},
[5] = {"checkrangeban", " %[line:Start Of IP Range] %[line:End Of IP Range]", "Check Bans For This IP Range", "Range Ban Admin",3},
},
[23] = {
[1] = {bDrop = 0},
[2] = {"drop", " %[line:Nick To Drop] %[line:Reason For Drop]", "Silent Kick With Tempban", "User Admin",1},
[3] = {"drop", " %[nick] %[line:Reason For Drop]", "Silent Kick With Tempban", "User Admin",2},
},
[24] = {
[1] = {bBan = 0},
[2] = {"ban", " %[nick] %[line:Reason For Ban]", "Ban By Nickname", "User Admin",1},
[3] = {"ban", " %[line:Nick To Ban] %[line:Reason For Ban]", "Ban By Nickname", "User Admin",2},
[4] = {"nickban", " %[line:Nick To Ban] %[line:Reason For Ban]", "Ban Nickname", "User Admin",1},
[5] = {"nickban", " %[nick] %[line:Reason For Ban]", "Ban Nickname", "User Admin",2},
[6] = {"banip", " %[line:Ban This IP] %[line:Reason For Ban]", "Ban IP Address", "User Admin",1},
[7] = {"banip", " %[ip] %[line:Reason For Ban]", "Ban IP Address", "User Admin",2},
[8] = {"fullbanip"," %[line:Ban This IP] %[line:Reason For Ban]", "FullBan IP Address", "User Admin",1},
[9] = {"fullbanip"," %[ip] %[line:Reason For Ban]", "FullBan IP Address", "User Admin",2},
},
[25] = {
[1] = {bRestartHub = 0},
[2] = {"restart", "", "Restart The Hub", "Hub Admin",3},
},
[26] = {
[1] = {bClrTempBan = 0},
[2] = {"clrtempbans", "", "Clear Temporary Bans", "Ban Admin",3},
},
}
for i,v in ipairs(Commands) do
local t = {}
for key,val in pairs(v[1]) do if perms[key] then t = v end end
if next(t) then
for a,b in ipairs(t) do
if a > 1 then
local uc,pre,p = "$UserCommand 1 "," $<%[mynick]> "..pfx,"&#124;|"
if i == 10 then pre = "" end
str = str..uc..b[5].." "..menu.."\\"..b[4].."\\"..b[3]..pre..b[1]..b[2]..p
end
end
end
end
return str
end

Powered By Leviathan™ 2nd Generation v. 1.4.2

Offline Massi

  • Junior Member
  • **
  • Posts: 22
  • Karma: +3/-0
Re: Command Px
« Reply #2 on: 30 June, 2021, 13:45:58 »
Thanks for your support and assistance ;)

Best Regards,
Massimiliano
¤ .:::[DC++ Community].:::.[Hobby, support, fun and passion]:::. ¤

PtokaX forum

Re: Command Px
« Reply #2 on: 30 June, 2021, 13:45:58 »