type assert fix

This commit is contained in:
hulb
2020-08-15 10:50:50 +08:00
parent cfec56c9b5
commit 84fc16357e
2 changed files with 23 additions and 6 deletions

View File

@@ -22,14 +22,22 @@ type TGChannelGetter struct {
func NewTGChannelGetter(options tool.Options) Getter {
num, found := options["num"]
if !found || num.(int) <= 0 {
num = 200
t := 200
switch num.(type) {
case int:
t = num.(int)
case float64:
t = int(num.(float64))
}
if !found || t <= 0 {
t = 200
}
url, found := options["channel"]
if found {
return &TGChannelGetter{
c: colly.NewCollector(),
NumNeeded: num.(int),
NumNeeded: t,
Url: "https://t.me/s/" + url.(string),
}
}

View File

@@ -22,14 +22,23 @@ type WebFanqiangdang struct {
func NewWebFanqiangdangGetter(options tool.Options) Getter {
num, found := options["num"]
if !found || num.(int) <= 0 {
num = 200
t := 200
switch num.(type) {
case int:
t = num.(int)
case float64:
t = int(num.(float64))
}
if !found || t <= 0 {
t = 200
}
url, found := options["url"]
if found {
return &WebFanqiangdang{
c: colly.NewCollector(),
NumNeeded: num.(int),
NumNeeded: t,
Url: url.(string),
}
}