mirror of
https://github.com/LBRYFoundation/lbry-tipbot.git
synced 2025-08-23 16:57:24 +00:00
refactor
This commit is contained in:
parent
430a8c874d
commit
e458fd5838
3 changed files with 13 additions and 10 deletions
23
app.js
23
app.js
|
@ -12,25 +12,28 @@ 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');
|
|
||||||
|
function sendWelcomeMessage(usertowelcome) {
|
||||||
|
request('https://raw.githubusercontent.com/lbryio/lbry.io/master/posts/other/slack-greeting.md', function (error, response, body) {
|
||||||
|
if (!error && response.statusCode == 200) {
|
||||||
|
slackbot.postMessage(usertowelcome, body);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var tipbot = require('./bots/tipbot');
|
||||||
tipbot.init(process.env.RPCUSER, process.env.RPCPASSWORD);
|
tipbot.init(process.env.RPCUSER, process.env.RPCPASSWORD);
|
||||||
|
|
||||||
var hashbot = require('./hashbot');
|
var hashbot = require('./bots/hashbot');
|
||||||
hashbot.init(slackbot, process.env.MINING_CHANNEL);
|
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') {
|
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.
|
setTimeout(function() { sendWelcomeMessage(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];
|
||||||
|
|
Loading…
Add table
Reference in a new issue