new plugins
kick.lua pokedex.lua router_status.lua whereisip.lua
This commit is contained in:
parent
dcccb2c8e9
commit
952271851e
2
.gitignore
vendored
2
.gitignore
vendored
@ -39,3 +39,5 @@ plugins/vine.lua
|
||||
plugins/youtube_playlist.lua
|
||||
plugins/yandere.lua
|
||||
plugins/e621.lua
|
||||
plugins/random.lua
|
||||
plugins/youtube_dl.lua
|
61
plugins/kick.lua
Normal file
61
plugins/kick.lua
Normal file
@ -0,0 +1,61 @@
|
||||
-- Kick an user from the chat group.
|
||||
-- Use !kick name User_name or !kick id id_number
|
||||
-- The User_name is the print_name (there are no spaces but _)
|
||||
|
||||
--~ TODO:
|
||||
--~ - !kick all
|
||||
--~ Get a list of users and kick them all (Useful for delete groups)
|
||||
--~ - !kick new // !protect
|
||||
--~ Kick each new user who entered in the group
|
||||
--~ - !ban user#id
|
||||
--~ Blacklist an user to enter a group
|
||||
|
||||
do
|
||||
|
||||
function ban(usr,chat)
|
||||
print ("Trying to kick: "..usr.." to "..chat)
|
||||
local success = chat_del_user (chat, usr, ok_cb, false)
|
||||
if not success then
|
||||
return "An error happened"
|
||||
else
|
||||
local kicked = "Kicked user: "..usr.." from "..chat
|
||||
return kicked
|
||||
end
|
||||
end
|
||||
|
||||
function run(msg, matches)
|
||||
chat_ = 'chat#id'..msg.to.id
|
||||
-- The message must come from a chat group OR
|
||||
if msg.to.type ~= 'chat' then
|
||||
return 'This isn\'t a chat group!'
|
||||
end
|
||||
|
||||
-- User submitted a user name
|
||||
if matches[1] == "name" then
|
||||
user_ = matches[2]
|
||||
user_ = string.gsub(user_," ","_")
|
||||
ban(user_,chat_)
|
||||
-- User submitted an id
|
||||
elseif matches[1] == "id" then
|
||||
for i=2,#matches do
|
||||
user_ = 'user#id'..matches[i]
|
||||
ban(user_,chat_)
|
||||
end
|
||||
end
|
||||
user_ = nil
|
||||
chat_ = nil
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Ban an user from the chat group. Credits: @Rutrus",
|
||||
usage = {
|
||||
"/kick name [user_name]",
|
||||
"/kick id [user_id]+" },
|
||||
patterns = {
|
||||
"^/kick (name) (.*)",
|
||||
"^/kick (id) (%d+)"
|
||||
},
|
||||
run = run,
|
||||
privileged = true
|
||||
}
|
||||
end
|
29
plugins/pokedex.lua
Normal file
29
plugins/pokedex.lua
Normal file
@ -0,0 +1,29 @@
|
||||
do
|
||||
|
||||
local function get_pokemon(query)
|
||||
local url = "http://pokeapi.co/api/v1/pokemon/" .. query .. "/"
|
||||
local b,c = http.request(url)
|
||||
local pokemon = json:decode(b)
|
||||
|
||||
if pokemon == nil then
|
||||
return 'No pokémon found.'
|
||||
end
|
||||
return 'Pokédex ID: ' .. pokemon.pkdx_id .. '\n'
|
||||
..'Name: ' .. pokemon.name .. '\n'
|
||||
..'Weight: ' .. pokemon.weight .. '\n'
|
||||
..'Height: ' .. pokemon.height .. '\n'
|
||||
..'Speed: ' .. pokemon.speed .. '\n'
|
||||
end
|
||||
|
||||
local function run(msg, matches)
|
||||
return get_pokemon(matches[1])
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Pokedex searcher for Telegram",
|
||||
usage = "/pokedex [Name/ID]: Search the pokédex for Name/ID and get info of the pokémon!",
|
||||
patterns = {"^/pokedex (.*)$"},
|
||||
run = run
|
||||
}
|
||||
|
||||
end
|
52
plugins/router_status.lua
Normal file
52
plugins/router_status.lua
Normal file
@ -0,0 +1,52 @@
|
||||
do
|
||||
|
||||
function getRouterStatus(attempt)
|
||||
command = "curl 'https://www.pcfactory.cl/ordenservicio' -H 'Pragma: no-cache' -H 'Origin: https://www.pcfactory.cl' -H 'Accept-Encoding: gzip,deflate' -H 'Accept-Language: en-US,en;q=0.8,es;q=0.6' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: no-cache' -H 'Referer: https://www.pcfactory.cl/ordenservicio' -H 'Cookie: PHPSESSID=i96mfj26t2cjgimojv08m7n934; SphinxID=5548c195553200.30873318; sphinxCONTACTO=0; __asc=014d05c814d24321517a9255ba1; __auc=2fe469c51466d6c6237c3ff1a1c' -H 'Connection: keep-alive' --data '%40sphinx=ORDENSERVICIO&rut=76247226-0&buscar=Buscar' --compressed | grep 'masinfo'"
|
||||
-- aRouterStatusattempt = attempt or 0
|
||||
-- attempt = attempt + 1
|
||||
|
||||
-- local res,status = http.request("")
|
||||
|
||||
-- if status ~= 200 then return nil end
|
||||
-- local data = json:decode(res)[1]
|
||||
|
||||
-- -- The OpenBoobs API sometimes returns an empty array
|
||||
-- if not data and attempt < 10 then
|
||||
-- print('Cannot get router status...')
|
||||
-- return getRouterStatus(attempt)
|
||||
-- end
|
||||
|
||||
local handle = io.popen(command)
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
function run(msg, matches)
|
||||
status = getRouterStatus()
|
||||
|
||||
if status ~= nil then
|
||||
return status
|
||||
else
|
||||
return 'Error getting boobs/butts for you, please try again later.'
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Gets the router status",
|
||||
usage = {
|
||||
"/router",
|
||||
"/router_status",
|
||||
"/routerstatus"
|
||||
},
|
||||
patterns = {
|
||||
"^/router$",
|
||||
"^/router_status$",
|
||||
"^/routerstatus$"
|
||||
},
|
||||
run = run
|
||||
}
|
||||
|
||||
end
|
40
plugins/whereisip.lua
Normal file
40
plugins/whereisip.lua
Normal file
@ -0,0 +1,40 @@
|
||||
do
|
||||
|
||||
function where_is_ip(msg, domain)
|
||||
local receiver = get_receiver(msg)
|
||||
ip = domain
|
||||
local res,code = http.request("http://freegeoip.net/json/" .. ip)
|
||||
if code ~= 200 then return "HTTP ERROR" end
|
||||
local data = json:decode(res)
|
||||
local location = data.country_code .. ":" .. data.country_name .. " - " .. data.city
|
||||
if data.region_name ~= "" then
|
||||
location = location .. " (" .. data.region_name .. ")"
|
||||
end
|
||||
message = data.ip .. " -> " .. location
|
||||
return send_msg(receiver, message, ok_cb, false)
|
||||
end
|
||||
end
|
||||
|
||||
function run(msg,matches)
|
||||
local receiver = get_receiver(msg)
|
||||
if matches[1] == "/whereisip" or matches[1] == "/ip" then
|
||||
message = "How to use:\n" .. matches[1] .. " nasa.gov\n"
|
||||
send_msg(receiver, message, ok_cb, false)
|
||||
return false
|
||||
else --~ matches[1] should be IP or domain
|
||||
vardump(matches)
|
||||
print (where_is_ip(msg,matches[1]))
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Send the origin of an IP or domain",
|
||||
usage = {"!ip (ip): Send the origin of an IP.\n!ip (domain.com) Looks for his IP origin.\nYou can find your ip in: http://lorenzomoreno.es/myip Credits: @rutrus"},
|
||||
patterns = {
|
||||
"^/whereisip$",
|
||||
"^/ip$",
|
||||
"^/whereisip ([%w.:]*)",
|
||||
"^!/ip ([%w.:]*)$"
|
||||
},
|
||||
run = run
|
||||
}
|
Reference in New Issue
Block a user