1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge branch 'master' into twitter-module

This commit is contained in:
Chris Cummer 2018-07-31 23:48:22 -04:00 committed by GitHub
commit 5ff893f5e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 31 deletions

View File

@ -287,6 +287,13 @@
"name": "ReadmeCritic", "name": "ReadmeCritic",
"avatar_url": "https://avatars3.githubusercontent.com/u/15367484?v=4", "avatar_url": "https://avatars3.githubusercontent.com/u/15367484?v=4",
"profile": "https://twitter.com/ReadmeCritic", "profile": "https://twitter.com/ReadmeCritic",
"contributions": []
},
{
"login": "jdevelop",
"name": "Eugene",
"avatar_url": "https://avatars0.githubusercontent.com/u/141402?v=4",
"profile": "https://github.com/jdevelop",
"contributions": [ "contributions": [
] ]
}, },

View File

@ -60,7 +60,7 @@ Thanks goes to these wonderful people:
| [<img src="https://avatars0.githubusercontent.com/u/5546718?v=4" width="48px;"/><br /><sub><b>flw</b></sub>](http://flw.tools/)<br /> | [<img src="https://avatars0.githubusercontent.com/u/6024927?v=4" width="48px;"/><br /><sub><b>David Barda</b></sub>](https://github.com/davebarda)<br /> | [<img src="https://avatars2.githubusercontent.com/u/4261980?v=4" width="48px;"/><br /><sub><b>Geoff Lee</b></sub>](https://github.com/matrinox)<br /> | [<img src="https://avatars3.githubusercontent.com/u/1022918?v=4" width="48px;"/><br /><sub><b>George Opritescu</b></sub>](http://international.github.io)<br /> | [<img src="https://avatars3.githubusercontent.com/u/497310?v=4" width="48px;"/><br /><sub><b>Grazfather</b></sub>](https://twitter.com/Grazfather)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1691120?v=4" width="48px;"/><br /><sub><b>Michael Cordell</b></sub>](http://www.mikecordell.com/)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1215497?v=4" width="48px;"/><br /><sub><b>Patrick José Pereira</b></sub>](http://patrick.ibexcps.com)<br /> | | [<img src="https://avatars0.githubusercontent.com/u/5546718?v=4" width="48px;"/><br /><sub><b>flw</b></sub>](http://flw.tools/)<br /> | [<img src="https://avatars0.githubusercontent.com/u/6024927?v=4" width="48px;"/><br /><sub><b>David Barda</b></sub>](https://github.com/davebarda)<br /> | [<img src="https://avatars2.githubusercontent.com/u/4261980?v=4" width="48px;"/><br /><sub><b>Geoff Lee</b></sub>](https://github.com/matrinox)<br /> | [<img src="https://avatars3.githubusercontent.com/u/1022918?v=4" width="48px;"/><br /><sub><b>George Opritescu</b></sub>](http://international.github.io)<br /> | [<img src="https://avatars3.githubusercontent.com/u/497310?v=4" width="48px;"/><br /><sub><b>Grazfather</b></sub>](https://twitter.com/Grazfather)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1691120?v=4" width="48px;"/><br /><sub><b>Michael Cordell</b></sub>](http://www.mikecordell.com/)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1215497?v=4" width="48px;"/><br /><sub><b>Patrick José Pereira</b></sub>](http://patrick.ibexcps.com)<br /> |
| [<img src="https://avatars2.githubusercontent.com/u/1483092?v=4" width="48px;"/><br /><sub><b>sherod taylor</b></sub>](https://github.com/sherodtaylor)<br /> | [<img src="https://avatars2.githubusercontent.com/u/3062663?v=4" width="48px;"/><br /><sub><b>Andrew Scott</b></sub>](http://cogentia.io)<br /> | [<img src="https://avatars2.githubusercontent.com/u/3252403?v=4" width="48px;"/><br /><sub><b>Anand Sudhir Prayaga</b></sub>](https://github.com/anandsudhir)<br /> | [<img src="https://avatars1.githubusercontent.com/u/12018440?v=4" width="48px;"/><br /><sub><b>Lassi Piironen</b></sub>](https://github.com/lsipii)<br /> | [<img src="https://avatars0.githubusercontent.com/u/14799210?v=4" width="48px;"/><br /><sub><b>BlackWebWolf</b></sub>](https://github.com/BlackWebWolf)<br /> | [<img src="https://avatars0.githubusercontent.com/u/1894885?v=4" width="48px;"/><br /><sub><b>andrewzolotukhin</b></sub>](https://github.com/andrewzolotukhin)<br /> | [<img src="https://avatars1.githubusercontent.com/u/8568280?v=4" width="48px;"/><br /><sub><b>Leon Stigter</b></sub>](https://retgits.github.io)<br /> | | [<img src="https://avatars2.githubusercontent.com/u/1483092?v=4" width="48px;"/><br /><sub><b>sherod taylor</b></sub>](https://github.com/sherodtaylor)<br /> | [<img src="https://avatars2.githubusercontent.com/u/3062663?v=4" width="48px;"/><br /><sub><b>Andrew Scott</b></sub>](http://cogentia.io)<br /> | [<img src="https://avatars2.githubusercontent.com/u/3252403?v=4" width="48px;"/><br /><sub><b>Anand Sudhir Prayaga</b></sub>](https://github.com/anandsudhir)<br /> | [<img src="https://avatars1.githubusercontent.com/u/12018440?v=4" width="48px;"/><br /><sub><b>Lassi Piironen</b></sub>](https://github.com/lsipii)<br /> | [<img src="https://avatars0.githubusercontent.com/u/14799210?v=4" width="48px;"/><br /><sub><b>BlackWebWolf</b></sub>](https://github.com/BlackWebWolf)<br /> | [<img src="https://avatars0.githubusercontent.com/u/1894885?v=4" width="48px;"/><br /><sub><b>andrewzolotukhin</b></sub>](https://github.com/andrewzolotukhin)<br /> | [<img src="https://avatars1.githubusercontent.com/u/8568280?v=4" width="48px;"/><br /><sub><b>Leon Stigter</b></sub>](https://retgits.github.io)<br /> |
| [<img src="https://avatars3.githubusercontent.com/u/21756?v=4" width="48px;"/><br /><sub><b>Amr Tamimi</b></sub>](https://tamimi.se)<br /> | [<img src="https://avatars3.githubusercontent.com/u/3717137?v=4" width="48px;"/><br /><sub><b>Jagdeep Singh</b></sub>](https://jagdeep.me)<br /> | [<img src="https://avatars0.githubusercontent.com/u/889171?v=4" width="48px;"/><br /><sub><b>Lineu Felipe</b></sub>](https://github.com/darkSasori)<br /> | [<img src="https://avatars2.githubusercontent.com/u/159124?v=4" width="48px;"/><br /><sub><b>Konstantin</b></sub>](https://github.com/kvj)<br /> | [<img src="https://avatars2.githubusercontent.com/u/6044920?v=4" width="48px;"/><br /><sub><b>Brendan O'Leary</b></sub>](http://www.brendanoleary.com)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1226441?v=4" width="48px;"/><br /><sub><b>bertl4398</b></sub>](https://github.com/bertl4398)<br /> | [<img src="https://avatars2.githubusercontent.com/u/6553695?v=4" width="48px;"/><br /><sub><b>Ferenc-</b></sub>](https://github.com/Ferenc-)<br /> | | [<img src="https://avatars3.githubusercontent.com/u/21756?v=4" width="48px;"/><br /><sub><b>Amr Tamimi</b></sub>](https://tamimi.se)<br /> | [<img src="https://avatars3.githubusercontent.com/u/3717137?v=4" width="48px;"/><br /><sub><b>Jagdeep Singh</b></sub>](https://jagdeep.me)<br /> | [<img src="https://avatars0.githubusercontent.com/u/889171?v=4" width="48px;"/><br /><sub><b>Lineu Felipe</b></sub>](https://github.com/darkSasori)<br /> | [<img src="https://avatars2.githubusercontent.com/u/159124?v=4" width="48px;"/><br /><sub><b>Konstantin</b></sub>](https://github.com/kvj)<br /> | [<img src="https://avatars2.githubusercontent.com/u/6044920?v=4" width="48px;"/><br /><sub><b>Brendan O'Leary</b></sub>](http://www.brendanoleary.com)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1226441?v=4" width="48px;"/><br /><sub><b>bertl4398</b></sub>](https://github.com/bertl4398)<br /> | [<img src="https://avatars2.githubusercontent.com/u/6553695?v=4" width="48px;"/><br /><sub><b>Ferenc-</b></sub>](https://github.com/Ferenc-)<br /> |
| [<img src="https://avatars1.githubusercontent.com/u/952036?v=4" width="48px;"/><br /><sub><b>Rohan Verma</b></sub>](http://rohanverma.net)<br /> | [<img src="https://avatars1.githubusercontent.com/u/19293566?v=4" width="48px;"/><br /><sub><b>Tim Fitzgerald</b></sub>](https://github.com/fimtitzgerald)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1081051?v=4" width="48px;"/><br /><sub><b>Federico Ruggi</b></sub>](https://github.com/ruggi)<br /> | [<img src="https://avatars2.githubusercontent.com/u/7293328?v=4" width="48px;"/><br /><sub><b>Craig Woodward</b></sub>](https://github.com/ctwoodward)<br /> | [<img src="https://avatars3.githubusercontent.com/u/15367484?v=4" width="48px;"/><br /><sub><b>ReadmeCritic</b></sub>](https://twitter.com/ReadmeCritic)<br /> | | [<img src="https://avatars1.githubusercontent.com/u/952036?v=4" width="48px;"/><br /><sub><b>Rohan Verma</b></sub>](http://rohanverma.net)<br /> | [<img src="https://avatars1.githubusercontent.com/u/19293566?v=4" width="48px;"/><br /><sub><b>Tim Fitzgerald</b></sub>](https://github.com/fimtitzgerald)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1081051?v=4" width="48px;"/><br /><sub><b>Federico Ruggi</b></sub>](https://github.com/ruggi)<br /> | [<img src="https://avatars2.githubusercontent.com/u/7293328?v=4" width="48px;"/><br /><sub><b>Craig Woodward</b></sub>](https://github.com/ctwoodward)<br /> | [<img src="https://avatars3.githubusercontent.com/u/15367484?v=4" width="48px;"/><br /><sub><b>ReadmeCritic</b></sub>](https://twitter.com/ReadmeCritic)<br /> | [<img src="https://avatars0.githubusercontent.com/u/141402?v=4" width="48px;"/><br /><sub><b>Eugene</b></sub>](https://github.com/jdevelop)<br /> |
<!-- ALL-CONTRIBUTORS-LIST:END --> <!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

View File

@ -7,12 +7,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/olebedev/config" "github.com/senorprogrammer/wtf/wtf"
) )
// Config is a pointer to the global config object
var Config *config.Config
var baseURL = "https://min-api.cryptocompare.com/data/price" var baseURL = "https://min-api.cryptocompare.com/data/price"
var ok = true var ok = true
@ -35,12 +32,12 @@ func NewWidget() *Widget {
} }
func (widget *Widget) setList() { func (widget *Widget) setList() {
currenciesMap, _ := Config.Map("wtf.mods.cryptolive.currencies") currenciesMap, _ := wtf.Config.Map("wtf.mods.cryptolive.currencies")
widget.list = &list{} widget.list = &list{}
for currency := range currenciesMap { for currency := range currenciesMap {
displayName, _ := Config.String("wtf.mods.cryptolive.currencies." + currency + ".displayName") displayName, _ := wtf.Config.String("wtf.mods.cryptolive.currencies." + currency + ".displayName")
toList := getToList(currency) toList := getToList(currency)
widget.list.addItem(currency, displayName, toList) widget.list.addItem(currency, displayName, toList)
} }
@ -70,10 +67,10 @@ func (widget *Widget) Refresh(wg *sync.WaitGroup) {
func (widget *Widget) display() { func (widget *Widget) display() {
str := "" str := ""
var ( var (
fromNameColor = Config.UString("wtf.mods.cryptolive.colors.from.name", "coral") fromNameColor = wtf.Config.UString("wtf.mods.cryptolive.colors.from.name", "coral")
fromDisplayNameColor = Config.UString("wtf.mods.cryptolive.colors.from.displayName", "grey") fromDisplayNameColor = wtf.Config.UString("wtf.mods.cryptolive.colors.from.displayName", "grey")
toNameColor = Config.UString("wtf.mods.cryptolive.colors.to.name", "white") toNameColor = wtf.Config.UString("wtf.mods.cryptolive.colors.to.name", "white")
toPriceColor = Config.UString("wtf.mods.cryptolive.colors.to.price", "green") toPriceColor = wtf.Config.UString("wtf.mods.cryptolive.colors.to.price", "green")
) )
for _, item := range widget.list.items { for _, item := range widget.list.items {
str += fmt.Sprintf(" [%s]%s[%s] (%s)\n", fromNameColor, item.displayName, fromDisplayNameColor, item.name) str += fmt.Sprintf(" [%s]%s[%s] (%s)\n", fromNameColor, item.displayName, fromDisplayNameColor, item.name)
@ -87,7 +84,7 @@ func (widget *Widget) display() {
} }
func getToList(fromName string) []*toCurrency { func getToList(fromName string) []*toCurrency {
toNames, _ := Config.List("wtf.mods.cryptolive.currencies." + fromName + ".to") toNames, _ := wtf.Config.List("wtf.mods.cryptolive.currencies." + fromName + ".to")
var toList []*toCurrency var toList []*toCurrency

View File

@ -8,11 +8,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/olebedev/config" "github.com/senorprogrammer/wtf/wtf"
) )
// Config is a pointer to the global config object
var Config *config.Config
var baseURL = "https://min-api.cryptocompare.com/data/top/exchanges" var baseURL = "https://min-api.cryptocompare.com/data/top/exchanges"
type textColors struct { type textColors struct {
@ -50,17 +48,17 @@ func NewWidget() *Widget {
} }
func (widget *Widget) setList() { func (widget *Widget) setList() {
currenciesMap, _ := Config.Map("wtf.mods.cryptolive.top") currenciesMap, _ := wtf.Config.Map("wtf.mods.cryptolive.top")
for fromCurrency := range currenciesMap { for fromCurrency := range currenciesMap {
displayName := Config.UString("wtf.mods.cryptolive.top."+fromCurrency+".displayName", "") displayName := wtf.Config.UString("wtf.mods.cryptolive.top."+fromCurrency+".displayName", "")
limit := Config.UInt("wtf.mods.cryptolive.top."+fromCurrency+".limit", 1) limit := wtf.Config.UInt("wtf.mods.cryptolive.top."+fromCurrency+".limit", 1)
widget.list.addItem(fromCurrency, displayName, limit, makeToList(fromCurrency, limit)) widget.list.addItem(fromCurrency, displayName, limit, makeToList(fromCurrency, limit))
} }
} }
func makeToList(fCurrencyName string, limit int) (list []*tCurrency) { func makeToList(fCurrencyName string, limit int) (list []*tCurrency) {
toList, _ := Config.List("wtf.mods.cryptolive.top." + fCurrencyName + ".to") toList, _ := wtf.Config.List("wtf.mods.cryptolive.top." + fCurrencyName + ".to")
for _, toCurrency := range toList { for _, toCurrency := range toList {
list = append(list, &tCurrency{ list = append(list, &tCurrency{
@ -74,11 +72,11 @@ func makeToList(fCurrencyName string, limit int) (list []*tCurrency) {
func (widget *Widget) config() { func (widget *Widget) config() {
// set colors // set colors
widget.colors.from.name = Config.UString("wtf.mods.cryptolive.colors.top.from.name", "coral") widget.colors.from.name = wtf.Config.UString("wtf.mods.cryptolive.colors.top.from.name", "coral")
widget.colors.from.displayName = Config.UString("wtf.mods.cryptolive.colors.top.from.displayName", "grey") widget.colors.from.displayName = wtf.Config.UString("wtf.mods.cryptolive.colors.top.from.displayName", "grey")
widget.colors.to.name = Config.UString("wtf.mods.cryptolive.colors.top.to.name", "red") widget.colors.to.name = wtf.Config.UString("wtf.mods.cryptolive.colors.top.to.name", "red")
widget.colors.to.field = Config.UString("wtf.mods.cryptolive.colors.top.to.field", "white") widget.colors.to.field = wtf.Config.UString("wtf.mods.cryptolive.colors.top.to.field", "white")
widget.colors.to.value = Config.UString("wtf.mods.cryptolive.colors.top.to.value", "value") widget.colors.to.value = wtf.Config.UString("wtf.mods.cryptolive.colors.top.to.value", "value")
} }
/* -------------------- Exported Functions -------------------- */ /* -------------------- Exported Functions -------------------- */

View File

@ -4,15 +4,11 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/olebedev/config"
"github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/price" "github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/price"
"github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/toplist" "github.com/senorprogrammer/wtf/cryptoexchanges/cryptolive/toplist"
"github.com/senorprogrammer/wtf/wtf" "github.com/senorprogrammer/wtf/wtf"
) )
// Config is a pointer to the global config object
var Config *config.Config
// Widget define wtf widget to register widget later // Widget define wtf widget to register widget later
type Widget struct { type Widget struct {
wtf.TextWidget wtf.TextWidget
@ -22,9 +18,6 @@ type Widget struct {
// NewWidget Make new instance of widget // NewWidget Make new instance of widget
func NewWidget() *Widget { func NewWidget() *Widget {
price.Config = Config
toplist.Config = Config
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" CryptoLive ", "cryptolive", false), TextWidget: wtf.NewTextWidget(" CryptoLive ", "cryptolive", false),
priceWidget: price.NewWidget(), priceWidget: price.NewWidget(),