-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fay Montage
committed
Feb 3, 2017
0 parents
commit 4650271
Showing
17 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_Store | ||
state | ||
node_modules | ||
docker-compose.yml | ||
.gradle | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
client: java $JAVA_OPTS -jar client/bin/token-headless-client.jar config/config-heroku.yml | ||
bot: node bot/src/bot.js config/config-heroku.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Token SOFA App | ||
|
||
## Developing a SOFA app for token | ||
|
||
### Bots | ||
|
||
### WebViews | ||
|
||
## Deploying | ||
|
||
### Deploy on Heroku | ||
|
||
### Deploy with Docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# latest official node image | ||
FROM node:latest | ||
|
||
RUN npm install -g nodemon | ||
|
||
# use cached layer for node modules | ||
#ADD package.json /tmp/package.json | ||
#RUN cd /tmp && npm install | ||
#RUN mkdir -p /usr/src/bot && cp -a /tmp/node_modules /usr/src/bot/ | ||
|
||
# add project files | ||
ADD . /usr/src/bot | ||
WORKDIR /usr/src/bot | ||
|
||
CMD npm install && nodemon -L src/bot.js config.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "token-bot-foundation", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "src/bot.js", | ||
"dependencies": { | ||
"token-headless-bot": "file:///usr/src/token-headless-bot" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "Token", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const SOFA = require('token-headless-bot').SOFA; | ||
const Bot = require('token-headless-bot').Bot; | ||
|
||
let bot = new Bot(); | ||
|
||
bot.hear('ping', (session, message) => { | ||
session.reply(SOFA.Message({body: "pong"})); | ||
}) | ||
|
||
bot.hear('SOFA::Init:', (session, message) => { | ||
session.reply("I will pay you at "+message.content.paymentAddress+" and speak to you in "+message.content.language); | ||
}) | ||
|
||
bot.hear('SOFA::Payment:', (session, message) => { | ||
session.reply("Thanks for the loot."); | ||
}) | ||
|
||
bot.hear('SOFA::PaymentRequest:', (session, message) => { | ||
session.reply("I ain't paying you a dime."); | ||
}) | ||
|
||
bot.hear('initMe', (session, message) => { | ||
session.reply(SOFA.InitRequest({ | ||
values: ['paymentAddress', 'language'] | ||
})); | ||
}) | ||
|
||
bot.hear('begMe', (session, message) => { | ||
session.reply(SOFA.PaymentRequest({ | ||
body: "Thanks for the great time! Can you send your share of the tab?", | ||
value: "0xce0eb154f900000", | ||
destinationAddress: "0x056db290f8ba3250ca64a45d16284d04bc6f5fbf" | ||
})); | ||
}) | ||
|
||
bot.hear('SOFA::Command:', (session, message) => { | ||
session.reply("I was commanded: ", message.content.value); | ||
}) | ||
|
||
bot.hear('buttons', (session, message) => { | ||
session.reply(SOFA.Message({ | ||
body: "Now let’s try sending some money. Choose a charity to make a donation of $0.01.", | ||
controls: [ | ||
{type: "button", label: "Red Cross", value: "red-cross"}, | ||
{type: "button", label: "Ethereum foundation", value: "ethereum-foundation"}, | ||
{type: "button", label: "GiveWell.org", value: "givewell.org"}, | ||
{type: "button", label: "Not now, thanks", value: null} | ||
] | ||
})); | ||
}) | ||
|
||
bot.hear('groups', (session, message) => { | ||
session.reply(SOFA.Message({ | ||
body: "What would you like me to do for you right now?", | ||
controls: [ | ||
{ | ||
type: "group", | ||
label: "Trip", | ||
controls: [ | ||
{type: "button", label: "Directions", action: "Webview:/Directions"}, | ||
{type: "button", label: "Timetable", value: "timetable"}, | ||
{type: "button", label: "Exit Info", value: "exit"}, | ||
{type: "button", label: "Service Conditions", action: "Webview:/ServiceConditions"} | ||
] | ||
},{ | ||
type: "group", | ||
label: "Services", | ||
controls: [ | ||
{type: "button", label: "Buy Ticket", action: "buy-ticket"}, | ||
{type: "button", label: "Support", value: "support"} | ||
] | ||
}, | ||
{type: "button", label: "Nothing", value: -1} | ||
], | ||
showKeyboard: false | ||
})); | ||
}) | ||
|
||
|
||
bot.hear('SOFA::Message:', (session, message) => { | ||
session.reply("I hear you "+session.address); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
task stage { | ||
//dummy to trigger Heroku gradle buildpack | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM openjdk:8 | ||
COPY . /usr/src/client | ||
WORKDIR /usr/src/client | ||
CMD ["java", "-jar", "bin/token-headless-client.jar", "config.yml"] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
server: https://token-chat-service.herokuapp.com | ||
store: store | ||
redis: | ||
envKey: REDIS_URL | ||
timeout: 2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
server: https://token-chat-service.herokuapp.com | ||
store: /state | ||
redis: | ||
envKey: REDIS_URL | ||
timeout: 2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: '2' | ||
services: | ||
client: | ||
build: client | ||
links: | ||
- redis | ||
environment: &environment | ||
- TOKEN_ADDRESS= | ||
- TOKEN_CLIENT_SEED= | ||
- REDIS_URL= | ||
volumes: | ||
- ./state/client:/state | ||
- ./config/config.yml:/usr/src/client/config.yml | ||
bot: | ||
build: bot | ||
links: | ||
- redis | ||
environment: *environment | ||
volumes: | ||
- ./state/bot:/state | ||
- ./config/config.yml:/usr/src/bot/config.yml | ||
- ./bot/src:/usr/src/bot/src | ||
redis: | ||
build: redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"scripts": { | ||
"postinstall": "cd bot && npm install" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
redis.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM redis | ||
COPY redis.conf /usr/local/etc/redis/redis.conf | ||
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
port 6379 | ||
timeout 0 | ||
loglevel notice | ||
databases 16 | ||
requirepass myNiceLongPassword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
java.runtime.version=1.8 |