60570e90f3
added example plugin with documentation added liberbot-compliant flood control see Liberbot Support for details on getting compliant added Kickass Torrent plugin various bugfixes all files seem to have been marked changed due to a shift in platform I will do a clean clone and testing to ensure there is no issue.
46 lines
946 B
Lua
Executable File
46 lines
946 B
Lua
Executable File
local PLUGIN = {}
|
|
|
|
PLUGIN.doc = [[
|
|
/loc <location>
|
|
Sends location data for query, taken from Google Maps. Works for countries, cities, landmarks, etc.
|
|
]]
|
|
|
|
PLUGIN.triggers = {
|
|
'^/loc'
|
|
}
|
|
|
|
function PLUGIN.action(msg)
|
|
|
|
local input = get_input(msg.text)
|
|
if not input then
|
|
if msg.reply_to_message then
|
|
msg = msg.reply_to_message
|
|
input = msg.text
|
|
else
|
|
return send_msg(msg, PLUGIN.doc)
|
|
end
|
|
end
|
|
|
|
local url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' .. URL.escape(input)
|
|
local jstr, res = HTTP.request(url)
|
|
|
|
if res ~= 200 then
|
|
return send_msg(msg, config.locale.errors.connection)
|
|
end
|
|
|
|
local jdat = JSON.decode(jstr)
|
|
|
|
if jdat.status ~= 'OK' then
|
|
local message = config.locale.errors.results
|
|
return send_msg(msg, message)
|
|
end
|
|
|
|
local lat = jdat.results[1].geometry.location.lat
|
|
local lng = jdat.results[1].geometry.location.lng
|
|
send_location(msg.chat.id, lat, lng, msg.message_id)
|
|
|
|
end
|
|
|
|
return PLUGIN
|
|
|