help plugin overwritten
thx @synk0
This commit is contained in:
		@@ -1,5 +1,19 @@
 | 
				
			|||||||
do
 | 
					do
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  function pairsByKeys(t, f)
 | 
				
			||||||
 | 
					    local a = {}
 | 
				
			||||||
 | 
					    for n in pairs(t) do table.insert(a, n) end
 | 
				
			||||||
 | 
					    table.sort(a, f)
 | 
				
			||||||
 | 
					    local i = 0      -- iterator variable
 | 
				
			||||||
 | 
					    local iter = function ()   -- iterator function
 | 
				
			||||||
 | 
					      i = i + 1
 | 
				
			||||||
 | 
					      if a[i] == nil then return nil
 | 
				
			||||||
 | 
					      else return a[i], t[a[i]]
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    return iter
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- Returns true if is not empty
 | 
					  -- Returns true if is not empty
 | 
				
			||||||
  local function has_usage_data(dict)
 | 
					  local function has_usage_data(dict)
 | 
				
			||||||
    if (dict.usage == nil or dict.usage == '') then
 | 
					    if (dict.usage == nil or dict.usage == '') then
 | 
				
			||||||
@@ -9,9 +23,24 @@ local function has_usage_data(dict)
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- Get commands for that plugin
 | 
					  -- Get commands for that plugin
 | 
				
			||||||
local function plugin_help(name)
 | 
					  local function plugin_help(name,number)
 | 
				
			||||||
  local plugin = plugins[name]
 | 
					    local plugin = ""
 | 
				
			||||||
 | 
					    if number then
 | 
				
			||||||
 | 
					      local i = 0
 | 
				
			||||||
 | 
					      for name in pairsByKeys(plugins) do
 | 
				
			||||||
 | 
					        if plugins[name].hide then
 | 
				
			||||||
 | 
					          name = nil
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          i = i + 1
 | 
				
			||||||
 | 
					          if i == tonumber(number) then
 | 
				
			||||||
 | 
					            plugin = plugins[name]
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      plugin = plugins[name]
 | 
				
			||||||
      if not plugin then return nil end
 | 
					      if not plugin then return nil end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local text = ""
 | 
					    local text = ""
 | 
				
			||||||
    if (type(plugin.usage) == "table") then
 | 
					    if (type(plugin.usage) == "table") then
 | 
				
			||||||
@@ -25,24 +54,36 @@ local function plugin_help(name)
 | 
				
			|||||||
    return text
 | 
					    return text
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  -- !help command
 | 
					  -- !help command
 | 
				
			||||||
  local function telegram_help()
 | 
					  local function telegram_help()
 | 
				
			||||||
  local text = "Plugin Liste: \n\n"
 | 
					    local i = 0
 | 
				
			||||||
 | 
					    local text = "Liste aller Plugins\n\n"
 | 
				
			||||||
    -- Plugins names
 | 
					    -- Plugins names
 | 
				
			||||||
  for name in pairs(plugins) do
 | 
					    for name in pairsByKeys(plugins) do
 | 
				
			||||||
    text = text..name..'\n'
 | 
					      if plugins[name].hide then
 | 
				
			||||||
 | 
					        name = nil
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        i = i + 1
 | 
				
			||||||
 | 
					        text = text..i..'. '..name..'\n'
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
  text = text..'\n'..'Benutze "/hilfe [Plugin Name]" für mehr Informationen'
 | 
					    end
 | 
				
			||||||
  text = text..'\n'..'Oder "/hilfe all" um alles zu sehen.'
 | 
					    text = text..'\n'..i.." Plugins sind zurzeit aktiviert"
 | 
				
			||||||
 | 
					    text = text..'\n'..'Benutze "/hilfe [Plugin Nummer]" fuer mehr Informationen'
 | 
				
			||||||
 | 
					    text = text..'\n'..'Fragen und/oder Anregungen: @Akamaru'
 | 
				
			||||||
    return text
 | 
					    return text
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -- !help all command
 | 
					    -- !help all command
 | 
				
			||||||
    local function help_all()
 | 
					    local function help_all()
 | 
				
			||||||
      local ret = ""
 | 
					      local ret = ""
 | 
				
			||||||
  for name in pairs(plugins) do
 | 
					      for name in pairsByKeys(plugins) do
 | 
				
			||||||
 | 
					        if plugins[name].hide then
 | 
				
			||||||
 | 
					          name = nil
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
          ret = ret .. plugin_help(name)
 | 
					          ret = ret .. plugin_help(name)
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
      return ret
 | 
					      return ret
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -52,7 +93,13 @@ local function run(msg, matches)
 | 
				
			|||||||
      elseif matches[1] == "/hilfe all" then
 | 
					      elseif matches[1] == "/hilfe all" then
 | 
				
			||||||
        return help_all()
 | 
					        return help_all()
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
    local text = plugin_help(matches[1])
 | 
					
 | 
				
			||||||
 | 
					        local text = ""
 | 
				
			||||||
 | 
					        if tonumber(matches[1])  then
 | 
				
			||||||
 | 
					          text = plugin_help(nil,matches[1])
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          text = plugin_help(matches[1])
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
        if not text then
 | 
					        if not text then
 | 
				
			||||||
          text = telegram_help()
 | 
					          text = telegram_help()
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user