-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
109 lines (103 loc) · 4.8 KB
/
bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
const { ActivityHandler, CardFactory } = require('botbuilder');
const axios = require('axios');
const emoji = require('node-emoji');
// emojis for later use
const dollarEmoji = emoji.get('dollar');
class MyBot extends ActivityHandler {
constructor() {
super();
// See https://aka.ms/about-bot-activity-message to learn more about the message and other activity types.
// Helper functions for cards
// function createAnimationCard(title, subtitle, url) {
// return CardFactory.animationCard(
// `${ title }`,
// [
// { url: `${ url }` }
// ],
// [],
// {
// subtitle: `${ subtitle }`
// }
// );
// }
this.onMessage(async (context, next) => {
// await context.sendActivity(`You said '${ context.activity.text }'`);
// await context.sendActivity('The WORLD is not ANYMORE the way it used to BE');
switch (context.activity.text) {
case '/btc':
case '/btc@BeetConnectBot':
let btcPrice = await axios.get('https://api.coinbase.com/v2/prices/BTC-USD/spot?currency=USD');
context.sendActivity('BTC $' + btcPrice.data.data.amount + ' ' + dollarEmoji);
break;
case '/ltc':
case '/ltc@BeetConnectBot':
let ltcPrice = await axios.get('https://api.coinbase.com/v2/prices/LTC-USD/spot?currency=USD');
// await context.sendActivity('LTC $' + ltcPrice.data.data.amount + ' ' + dollarEmoji);
await context.sendActivity('LTC $' + ltcPrice.data.data.amount + ' ' + dollarEmoji);
break;
case '/eth':
case '/eth@BeetConnectBot':
let ethPrice = await axios.get('https://api.coinbase.com/v2/prices/ETH-USD/spot?currency=USD');
context.sendActivity('ETH $' + ethPrice.data.data.amount + ' ' + dollarEmoji);
break;
case '/xrp':
case '/xrp@BeetConnectBot':
let xrpPrice = await axios.get('https://api.coinbase.com/v2/prices/XRP-USD/spot?currency=USD');
context.sendActivity('XRP $' + xrpPrice.data.data.amount + ' ' + dollarEmoji);
break;
case '/link':
case '/link@BeetConnectBot':
let linkPrice = await axios.get('https://api.coinbase.com/v2/prices/LINK-USD/spot?currency=USD');
context.sendActivity('LINK $' + linkPrice.data.data.amount + ' ' + dollarEmoji);
break;
case '/bitconnect':
case '/bitconnect@BeetConnectBot':
context.sendActivity('https://youtu.be/e5nyQmaq4k4');
break;
case '/moon':
case '/moon@BeetConnectBot':
context.sendActivity('https://gfycat.com/agiletastyindianjackal');
break;
case '/hi':
case '/hi@BeetConnectBot':
context.sendActivity(emoji.get('wave') + ' Wassa wassa wassa wassa wassa wassa WASSUP BITCONNECT');
break;
case '/rocket':
case '/rocket@BeetConnectBot':
// await context.sendActivity('https://gfycat.com/agiletastyindianjackal');
let rocketCard = CardFactory.animationCard(
'',
[
{ url: 'https://giant.gfycat.com/DeadlyVeneratedAmericangoldfinch.gif' }
],
[],
{
subtitle: 'THE WORLD IS NO LONGER THE WAY THAT IT USED TO BE'
}
);
// let rocketCard = createAnimationCard(
// 'test',
// 'https://giant.gfycat.com/DeadlyVeneratedAmericangoldfinch.gif',
// 'THE WORLD IS NO LONGER THE WAY THAT IT USED TO BE'
// );
context.sendActivity({ attachments: [rocketCard] });
break;
}
// By calling next() you ensure that the next BotHandler is run.
await next();
});
// this.onMembersAdded(async (context, next) => {
// const membersAdded = context.activity.membersAdded;
// for (let cnt = 0; cnt < membersAdded.length; ++cnt) {
// if (membersAdded[cnt].id !== context.activity.recipient.id) {
// await context.sendActivity('Hello and welcome!');
// }
// }
// // By calling next() you ensure that the next BotHandler is run.
// await next();
// });
}
}
module.exports.MyBot = MyBot;