Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 88d27fe

Browse files
author
kirito
committed
日报周报不打印小额地址
1 parent d6e8c5e commit 88d27fe

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

callback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func now(update *tgbotapi.Update) {
5555
}
5656
}
5757

58-
rep := calc(want, timenow.Unix())
58+
rep := calc(want, timenow.Unix(), 5000000)
5959
rep.Time = "#简报"
6060

6161
msg.Text = ParseToString("report", rep)

live.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ func daily() {
160160
<- time.After(dur)
161161
last0 := time.Date(now.Year(), now.Month(), now.Day(), 0,0,0,0, now.Location())
162162
// 开始执行 0 点任务
163-
btcrep := calc("btc", last0.Unix())
164-
usdtrep := calc("usdt", last0.Unix())
163+
btcrep := calc("btc", last0.Unix(), 5000000) // 500w$ 才会打印
164+
usdtrep := calc("usdt", last0.Unix(), 5000000)
165165
btcrep.Time = "#日报"
166166
usdtrep.Time = "#日报"
167167
doReport(btcrep)
@@ -170,8 +170,8 @@ func daily() {
170170
t:= time.Now()
171171
if t.Weekday() == 0 { // 一周任务
172172
nt := t.AddDate(0,0,-7)
173-
btcrep := calc("btc", nt.Unix())
174-
usdtrep := calc("usdt", nt.Unix())
173+
btcrep := calc("btc", nt.Unix(), 25000000)
174+
usdtrep := calc("usdt", nt.Unix(), 25000000)
175175
btcrep.Time = "#周报"
176176
usdtrep.Time = "#周报"
177177
doReport(btcrep)
@@ -197,7 +197,7 @@ func doReport(rep *report) {
197197
}
198198

199199
// 统计币种情况, 不会返回 nil
200-
func calc(currency string, timestamp int64) *report{
200+
func calc(currency string, timestamp int64, minVal int64) *report{
201201
re := &report{
202202
Name: currency,
203203
Data: make(map[string]*reportData),
@@ -241,7 +241,12 @@ func calc(currency string, timestamp int64) *report{
241241
re.IN_usd += alert.AmountUsd // 流入交易所
242242
}
243243
}
244-
244+
}
245+
// 交易额小于 minVal 美元的不显示
246+
for k,v := range re.Data {
247+
if v.TotalIn_usd + v.TotalOut_usd < minVal {
248+
delete(re.Data, k)
249+
}
245250
}
246251
return re
247252
}

static/report.tmp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{{.Time}} 统计: *{{.Name}}* 🔊🔊🔊
22
```
3-
{{range $k,$v := .Data}}
4-
{{$k}}:
3+
{{range $k,$v := .Data}}{{$k}}:
54
- 转入 {{$v.TotalIn |Itoa| Comma}} 未知来源{{$v.UnknownIN |Itoa| Comma}}
65
- 转出 {{$v.TotalOut |Itoa| Comma}} 未知去向{{$v.UnknownOut |Itoa| Comma}}
76
{{end}}

template_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func Test_daily(t *testing.T) {
5252
_ = time.Date(futher.Year(), futher.Month(), futher.Day(), 0,0,0,0, futher.Location())
5353
//<- time.After(time.Second * time.Duration(t0.Unix()-now.Unix()))
5454
last0 := time.Date(now.Year(), now.Month(), now.Day(), 0,0,0,0, now.Location())
55-
report := calc("btc", last0.Unix())
55+
report := calc("btc", last0.Unix(), 5)
5656
for k,v := range report.Data {
5757
t.Log(k)
5858
t.Log(v)
@@ -61,7 +61,7 @@ func Test_daily(t *testing.T) {
6161
text := ParseToString("report", report)
6262
//t.Log(text)
6363
log.Print(text)
64-
report = calc("usdt", 0)
64+
report = calc("usdt", 0, 5)
6565
report.Time = "#日报"
6666
text = ParseToString("report", report)
6767
log.Print(text)

0 commit comments

Comments
 (0)