mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-08-23 17:47:27 +00:00
Merge pull request #1 from Fillerix99/welcome
Added welcome message function!
This commit is contained in:
commit
430a8c874d
2 changed files with 12 additions and 1 deletions
10
app.js
10
app.js
|
@ -1,4 +1,5 @@
|
||||||
var SlackBot = require('slackbots');
|
var SlackBot = require('slackbots');
|
||||||
|
var request = require('request');
|
||||||
|
|
||||||
['SLACK_TOKEN', 'RPCUSER', 'RPCPASSWORD'].forEach(function(envVar) {
|
['SLACK_TOKEN', 'RPCUSER', 'RPCPASSWORD'].forEach(function(envVar) {
|
||||||
if (!process.env[envVar]) {
|
if (!process.env[envVar]) {
|
||||||
|
@ -11,6 +12,12 @@ var slackbot = new SlackBot({
|
||||||
name: 'wunderbot'
|
name: 'wunderbot'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function sendwelcomemsg(usertowelcome) {
|
||||||
|
request('https://raw.githubusercontent.com/lbryio/lbry.io/master/posts/other/slack-greeting.md', function (error, response, body) {
|
||||||
|
if (!error && response.statusCode == 200) {
|
||||||
|
bot.postMessage(usertowelcome, body);
|
||||||
|
}
|
||||||
|
})};
|
||||||
|
|
||||||
var tipbot = require('./tipbot');
|
var tipbot = require('./tipbot');
|
||||||
tipbot.init(process.env.RPCUSER, process.env.RPCPASSWORD);
|
tipbot.init(process.env.RPCUSER, process.env.RPCPASSWORD);
|
||||||
|
@ -22,6 +29,9 @@ hashbot.init(slackbot, process.env.MINING_CHANNEL);
|
||||||
|
|
||||||
slackbot.on('start', function() {
|
slackbot.on('start', function() {
|
||||||
slackbot.on('message', function(data) {
|
slackbot.on('message', function(data) {
|
||||||
|
if (data.type == 'team_join') {
|
||||||
|
setTimeout(function() { sendwelcomemsg(data.user.id); },2000); //Delay because of slow slack api updates which sometimes does not send msg.
|
||||||
|
}
|
||||||
if (data.text) {
|
if (data.text) {
|
||||||
var command = data.text.trim().split(' ')[0];
|
var command = data.text.trim().split(' ')[0];
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bitcoin": "^3.0.1",
|
"bitcoin": "^3.0.1",
|
||||||
"needle": "^1.0.0",
|
"needle": "^1.0.0",
|
||||||
"slackbots": "^0.5.1"
|
"slackbots": "^0.5.1",
|
||||||
|
"request": "^2.74.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue