-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.coffee
27 lines (23 loc) · 871 Bytes
/
index.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
express = require 'express'
bodyparser = require 'body-parser'
config = require('./config.json')
app = express()
port = config.port
app.use bodyparser.urlencoded
extended: yes
app.post '/', (req, res) ->
if req.body.token isnt config.token
return res.status(404).send 'not found'
coords = req.body.text.split("maps?q=")[1].split(">")[0].split(',')
maps_picture_url = "https://maps.googleapis.com/maps/api/staticmap?center=#{coords[0]},#{coords[1]}&markers=#{coords[0]},#{coords[1]}&zoom=16&size=640x400&key=#{config.gmapsToken}"
resObj =
text: "Picture for #{req.body.user_name} Maps Link"
attachments:[
{
fallback: "ficken!"
image_url: maps_picture_url
}
]
res.send resObj
app.listen port, () ->
console.log "Slack Bot is listening on Port #{port}"