JavaScript is required to use Bungie.net

Group Avatar

BungieNetPlatform

「Updates, discussions, and documentation of the BungieNetPlatform API.」

請求加入
原先發佈於: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]

文章張貼語言:

 

以禮待人。發佈文章前請花點時間查看我們的行為準則 取消 編輯 創立火力戰隊 文章

檢視完整主題
你無權檢閱此內容
;
preload icon
preload icon
preload icon