JavaScript is required to use Bungie.net

Group Avatar

BungieNetPlatform

"Updates, discussions, and documentation of the BungieNetPlatform API."

Request Join
originally posted in:BungieNetPlatform
2/22/2017 12:31:10 AM
1

Slightly off-topic Slack bot

Our clan uses Slack for keeping in touch. I created a Slack bot that utilizes the Slack real-time API to welcome new Destiny guardians to the clan. The bot is written in node.js and deployed in AWS utlizing Elastik Beanstalk. The welcome message is stored in a flat file that is read at run time. I had hoped I could change the contents of the flat file without deploying each time a change was requested. Unfortunately, I was wrong but am too lazy to bring the message into the main code as a variable :-) The Slack token and channel are stored in process.env as part of the Elastik Beanstalk configuration. So Destiny related but not really :-) Jason [quote] var fs = require('fs'); var token = process.env.token; var RtmClient = require('@slack/client').RtmClient; var RTM_EVENTS = require('@slack/client').RTM_EVENTS; var rtm = new RtmClient(token); rtm.start(); rtm.on(RTM_EVENTS.TEAM_JOIN, function handleRtmTeamJoin(team) { var channel = process.env.channel; var welcome = fs.readFileSync('welcome.msg', 'utf8'); rtm.sendMessage('<@' + team.user.id + '> welcome to Iron Orange! ' + welcome, channel); console.log('User added:', team); }); [/quote]

Posting in language:

 

Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

View Entire Topic
You are not allowed to view this content.
;
preload icon
preload icon
preload icon