cinch-bitcoin 1.0.1 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/cinch/plugins/bitcoin.rb +71 -31
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 722128b145f5b5c1ea0b76384a0735306a94fc31
|
4
|
+
data.tar.gz: a45cdf2f0f613339707d9e96718f3bffb80fcbc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e38c2fdf308eb4ac5ee282c2f3d2275313eb7d6b1b4989d349703809334c7f3f474fe43bd7964d8adf89aee2b6a5fbe7d21f3ef3d2dd624bb3f7221d79d7b1a5
|
7
|
+
data.tar.gz: dccdfbc5e09bdf70683692a2f5b04f13823c9c597f517d4bf82f2a5f77c6ae73e47ffaf6d1fd5908008711c707e276579f11ab30d1278711a65548015f6dc6bf
|
@@ -1,31 +1,71 @@
|
|
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
|
-
|
1
|
+
require 'cinch'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Cinch
|
7
|
+
module Plugins
|
8
|
+
class Bitcoin
|
9
|
+
include Cinch::Plugin
|
10
|
+
|
11
|
+
set :plugin_name, 'bitcoin'
|
12
|
+
set :help, <<-USAGE.gsub(/^ {6}/, '')
|
13
|
+
Bitcoin plugin that fetches results from Blockchain.info!
|
14
|
+
Usage:
|
15
|
+
* !btcv <currency>: Returns the latest value of 1 (one) Bitcoin in <currency>
|
16
|
+
* !btc <currency> <Bitcoin amount>: Returns the value of <Bitcoin amount> in <currency>.
|
17
|
+
USAGE
|
18
|
+
|
19
|
+
match /btcv (\w{3})/
|
20
|
+
|
21
|
+
def execute(m, currency)
|
22
|
+
data = JSON.parse(open("http://blockchain.info/ticker").read)
|
23
|
+
|
24
|
+
coins = ['USD', 'CNY', 'JPY', 'SGD', 'HKD', 'CAD', 'NZD', 'AUD', 'CLP', 'GBP', 'HKK', 'SEK', 'ISK', 'CHF', 'BRL', 'EUR', 'RUB', 'PLN', 'THB', 'KRW', 'TWD']
|
25
|
+
|
26
|
+
currency = currency.upcase
|
27
|
+
|
28
|
+
if !coins.include?(currency)
|
29
|
+
m.reply "That currency isn't in my database!"
|
30
|
+
m.user.notice "You can use: #{coins}"
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
34
|
+
value = data[currency]['15m']
|
35
|
+
value = value.round(2).to_f
|
36
|
+
value = value.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
|
37
|
+
|
38
|
+
symbol = data[currency]['symbol']
|
39
|
+
|
40
|
+
m.reply "Current value of 1 BTC in #{currency} is: #{symbol}#{value}", true
|
41
|
+
end
|
42
|
+
|
43
|
+
match /btc (\w{3}) (.+)/, method: :conversion
|
44
|
+
|
45
|
+
def conversion(m, currency, btc)
|
46
|
+
data = JSON.parse(open("http://blockchain.info/ticker").read)
|
47
|
+
|
48
|
+
coins = ['USD', 'CNY', 'JPY', 'SGD', 'HKD', 'CAD', 'NZD', 'AUD', 'CLP', 'GBP', 'HKK', 'SEK', 'ISK', 'CHF', 'BRL', 'EUR', 'RUB', 'PLN', 'THB', 'KRW', 'TWD']
|
49
|
+
|
50
|
+
currency = currency.upcase
|
51
|
+
|
52
|
+
if !coins.include?(currency)
|
53
|
+
m.reply "That currency isn't in my database!"
|
54
|
+
m.user.notice "You can use: #{coins}"
|
55
|
+
return
|
56
|
+
end
|
57
|
+
value = data[currency]['15m']
|
58
|
+
value = value.round(2).to_f
|
59
|
+
|
60
|
+
symbol = data[currency]['symbol']
|
61
|
+
|
62
|
+
btc = btc.to_f
|
63
|
+
|
64
|
+
conv = (btc * value).round(2)
|
65
|
+
conv = conv.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
|
66
|
+
|
67
|
+
m.reply "The value of #{btc}BTC is #{symbol}#{conv}.", true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-bitcoin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Banks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cinch
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.1.0
|
27
|
-
description:
|
28
|
-
|
29
|
-
issues , test the gem, or just chat.'
|
27
|
+
description: 'A gem/plugin for the Cinch IRC Framework that returns the value of Bitcoin
|
28
|
+
in the specified currency. You can visit irc://rawr.sinsira.net #Lobby to get help,
|
29
|
+
report issues , test the gem, or just chat.'
|
30
30
|
email:
|
31
31
|
- namaste@rawrnet.net
|
32
32
|
executables: []
|
@@ -44,19 +44,19 @@ require_paths:
|
|
44
44
|
- lib
|
45
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
requirements: []
|
56
|
-
rubyforge_project:
|
57
|
-
rubygems_version: 2.
|
56
|
+
rubyforge_project: "[none]"
|
57
|
+
rubygems_version: 2.2.2
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: A gem/plugin for the Cinch IRC Framework that returns the value of Bitcoin
|
61
|
-
in
|
61
|
+
in the specified currency.
|
62
62
|
test_files: []
|