Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nanobot4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cool Fire
nanobot4
Commits
24926372
Commit
24926372
authored
Mar 14, 2018
by
Cool Fire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move dogecoin plugin away from discontinued API
parent
f5cd78d9
Pipeline
#561
passed with stages
in 3 minutes and 29 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
20 deletions
+14
-20
plugins/dogecoin.rb
plugins/dogecoin.rb
+14
-20
No files found.
plugins/dogecoin.rb
View file @
24926372
...
...
@@ -14,37 +14,31 @@ class Dogecoin
@irc
=
irc
@timer
=
timer
@api_host
=
'pubapi.cryptsy.com'
@api_path
=
'/api.php?method=singlemarketdata&marketid=132'
@last
=
BigDecimal
.
new
(
"0.0"
)
@api_uri
=
'https://api.cryptonator.com/api/ticker/doge-btc'
@last
=
BigDecimal
(
"0.0"
)
end
# Alias for last
def
main
(
_nick
,
_user
,
_host
,
from
,
_msg
,
_arguments
,
con
)
uri
=
URI
.
parse
(
"http://
#{
@api_host
}#{
@api_path
}
"
)
http
=
Net
::
HTTP
.
new
(
uri
.
host
,
uri
.
port
)
request
=
Net
::
HTTP
::
Get
.
new
(
uri
.
request_uri
)
response
=
http
.
request
(
request
)
result
=
JSON
.
parse
(
response
.
body
)
uri
=
URI
(
@api_uri
)
response
=
Net
::
HTTP
.
get
(
uri
)
puts
response
result
=
JSON
.
parse
(
response
)
# Calculate delta from last !btc
ldiff
=
BigDecimal
.
new
(
result
[
'return'
][
'markets'
][
'DOGE'
][
'lasttradeprice'
]
)
-
@last
puts
result
.
inspect
# Calculate delta from last !doge
ldiff
=
BigDecimal
(
result
[
'ticker'
][
'price'
]
)
-
@last
if
(
ldiff
>
0
)
ldiff
=
"+
#{
ldiff
}
"
else
ldiff
=
"
#{
ldiff
}
"
end
@last
=
BigDecimal
.
new
(
result
[
'return'
][
'markets'
][
'DOGE'
][
'lasttrade
price'
]
)
@last
=
BigDecimal
(
result
[
'ticker'
][
'
price'
]
)
rounded
=
"
#{
(
BigDecimal
.
new
(
result
[
'return'
][
'markets'
][
'DOGE'
][
'lasttrade
price'
]
)
*
100
).
round
/
100.0
}
"
rounded
=
"
#{
(
BigDecimal
(
result
[
'ticker'
][
'
price'
]
)
*
100
).
round
/
100.0
}
"
line
=
"Crypt
sy DOGE/BTC rate:
#{
rounded
}
(
#{
result
[
'return'
][
'markets'
][
'DOGE'
][
'lasttrade
price'
]
}
) (
#{
ldiff
}
since last !doge)"
line
=
"Crypt
onator DOGE/BTC rate:
#{
rounded
}
(
#{
result
[
'ticker'
][
'
price'
]
}
) (
#{
ldiff
}
since last !doge)"
if
(
con
)
@output
.
c
(
line
+
"
\n
"
)
...
...
@@ -56,10 +50,10 @@ class Dogecoin
# Function to send help about this plugin (Can also be called by the help plugin.)
def
help
(
nick
,
_user
,
_host
,
_from
,
_msg
,
_arguments
,
con
)
help
=
[
"Gets current litecoin values from
Btc-e
"
,
"Gets current litecoin values from
cryptonator
"
,
" dogecoin - Get DOGE/BTC exchange rate"
]
# Print out help
help
.
each
do
|
line
|
if
(
con
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment