Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit bcc0326

Browse files
author
Tom Bell
committed
Merge pull request #946 from matteoagosti/master
A couple of additional scripts
2 parents adfa731 + dab7008 commit bcc0326

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

src/scripts/fastspring.coffee

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Description
2+
# An HTTP listener for FastSpring payment notifications
3+
#
4+
# Dependencies:
5+
# None
6+
#
7+
# Configuration:
8+
# HUBOT_FASTSPRING_PRIVATE_KEY
9+
#
10+
# Commands:
11+
# None
12+
#
13+
# URLS:
14+
# POST /hubot/fastspring
15+
# room=<room>
16+
# fullName=<customer's full name>
17+
# email=<customer's email>
18+
# productName=<product name, can also be an array of products>
19+
# totalPriceValue=<total price value>
20+
# totalPriceCurrency=<total price currency>
21+
# url=<invoice's url>
22+
#
23+
# Notes:
24+
# See FastSpring notifications overview for further details
25+
# https://support.fastspring.com/entries/236490-Notifications-Overview
26+
#
27+
# Author:
28+
# matteoagosti
29+
30+
http = require "http"
31+
querystring = require "querystring"
32+
crypto = require "crypto"
33+
34+
module.exports = (robot) ->
35+
privateKey = process.env.HUBOT_FASTSPRING_PRIVATE_KEY
36+
37+
unless privateKey
38+
robot.logger.error "Please set the HUBOT_FASTSPRING_PRIVATE_KEY environment variable."
39+
return
40+
41+
robot.router.post "/hubot/fastspring", (req, res) ->
42+
query = req.body
43+
res.end
44+
45+
unless query.room
46+
return
47+
48+
unless crypto.createHash("md5").update(query.security_data + privateKey, 'utf8').digest('hex') is query.security_hash
49+
return
50+
51+
robot.messageRoom query.room, "#{query.fullName} (#{query.email}) just bought #{query.productName} for #{query.totalPriceValue}#{query.totalPriceCurrency}. #{query.url}"

src/scripts/tiptop.coffee

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Description:
2+
# Hubot, be Swissy and enjoy team exults.
3+
# Whenever TIP TOP or TOP is being said Hubot will reply back.
4+
#
5+
# Dependencies:
6+
# None
7+
#
8+
# Configuration:
9+
# None
10+
#
11+
# Commands:
12+
# None
13+
#
14+
# Notes:
15+
# Consecutive hops will be ignored.
16+
#
17+
# Author:
18+
# matteoagosti
19+
20+
module.exports = (robot) ->
21+
robot.hear /.+/i, (msg) ->
22+
unless msg.message.text is "TOP" or msg.message.text is "TIP TOP"
23+
robot.brain.data.tiptop = null
24+
return
25+
26+
unless robot.brain.data.tiptop is null
27+
return
28+
29+
msg.send msg.message.text
30+
robot.brain.data.tiptop = true

0 commit comments

Comments
 (0)