This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/otouto/plugins/gps.lua
Andreas Bielawski c484023791 - Portierung folgender Plugins:
+ Games
+ GDrive
+ Gfycat
+ Googl
+ GPS
+ Hackernews
+ Hello
+ Instagram
+ IP_info
+ GMaps so angepasst, dass es wie Location funktioniert
- Bugfixes, Pattern-Fixes, etc.
2016-06-19 19:25:24 +02:00

39 lines
1.2 KiB
Lua

local gps = {}
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
gps.command = 'gps <Breitengrad>,<Längengrad>'
function gps:init(config)
gps.triggers = {
"^/gps ([^,]*)[,%s]([^,]*)$",
"google.de/maps/@([^,]*)[,%s]([^,]*)",
"google.com/maps/@([^,]*)[,%s]([^,]*)",
"google.de/maps/place/@([^,]*)[,%s]([^,]*)",
"google.com/maps/place/@([^,]*)[,%s]([^,]*)"
}
gps.doc = [[*
]]..config.cmd_pat..[[gps* _<Breitengrad>_,_<Längengrad>_: Sendet Karte mit diesen Koordinaten]]
end
function gps:action(msg, config, matches)
utilities.send_typing(self, msg.chat.id, 'upload_photo')
local lat = matches[1]
local lon = matches[2]
local zooms = {16, 18}
local urls = {}
for i in ipairs(zooms) do
local zoom = zooms[i]
local url = "https://maps.googleapis.com/maps/api/staticmap?zoom=" .. zoom .. "&size=600x300&maptype=hybrid&center=" .. lat .. "," .. lon .. "&markers=color:red%7Clabel:•%7C" .. lat .. "," .. lon
local file = download_to_file(url, 'zoom_'..i..'.png')
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
end
utilities.send_location(self, msg.chat.id, lat, lon, msg.message_id)
end
return gps