Skip to content
This repository has been archived by the owner on Jan 22, 2023. It is now read-only.

Add Cryptsy Price Ticker for MYR #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bin/tipbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var irc = require('irc'),
yaml = require('js-yaml'),
coin = require('node-dogecoin'),
webadmin = require('../lib/webadmin/app');
var Cryptsy = require('cryptsy');

// check if the config file exists
if(!fs.existsSync('./config/config.yml')) {
Expand All @@ -22,6 +23,9 @@ process.on('exit', function() {
// load settings
var settings = yaml.load(fs.readFileSync('./config/config.yml', 'utf-8'));

// Load Cryptsy
var cryptsy = new Cryptsy(settings.cryptsy.key, settings.cryptsy.secret);

// load winston's cli defaults
winston.cli();

Expand Down Expand Up @@ -268,6 +272,17 @@ client.addListener('message', function(from, channel, message) {
}
})
break;
case 'price':
cryptsy.api('singlemarketdata', { marketid: 200 }, function (err, data) {
if(err) {
winston.error('Error in !price command.', err);
client.say(channel, settings.messages.error.expand({name: from}));
return;
}
winston.info('Fetched MYR Price From Cryptsy')
client.say(channel, settings.messages.price.expand({amount: data}));
});
break;
case 'tip':
var match = message.match(/^.?tip (\S+) (random)?([\d\.]+)/);
if(match == null || match.length < 3) {
Expand Down
7 changes: 7 additions & 0 deletions config/config.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ channels:
- '##tipbots'
log:
file: tipbot.log
cryptsy:
key: API_KEY_HERE
secret: API_SECRET_HERE
rpc:
host: localhost
port: 22555
Expand Down Expand Up @@ -50,11 +53,15 @@ commands:
terms:
pm: true
channel: false
price:
pm: true
channel: true
rain:
pm: false
channel: true
rain_on_last_active: 0 # amount in seconds. rain tips will fall only on users active within x seconds. leave 0 for no such behavior.
messages:
price: 'MYR is current priced at %amount% BTC on cryptsy'
error: 'Sorry %name%, something went wrong.'
no_funds: "Sorry %name%, you don't have enough funds (you're %short%%short_name% short)"
not_identified: '%name%: You need to be identified with NickServ to tip.'
Expand Down