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

Commit d6e8c5e

Browse files
author
kirito
committed
v0.2.0 稳定版本
1 parent 4b92d1f commit d6e8c5e

File tree

10 files changed

+46
-13
lines changed

10 files changed

+46
-13
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ Telegram Bot [@btcinfo_kirito_bot](https://t.me/btcinfo_kirito_bot) 暴躁老哥
4040
* `whale_apikey` - rss功能需要的apikey,[WhaleAlert](https://docs.whale-alert.io/#introduction),留空为不启用
4141
* 启用后,要用`setup.sql`初始化mysql数据库
4242
* 并填写相关设置
43+
* `rss` - 服务器启动时,这些频道自动订阅
4344
* 其余保持默认
4445
* 执行 `./fkbro.exe -c config.json` ,也可以不用`-c`参数,默认执行目录下`config.json`
4546
* [release](https://github.com/zshorz/fkbro/releases) 里已经为Linux提供了编译好的二进制文件
4647

48+
## 关于
49+
* 版本号格式 `x.y.z` - `y`为偶数的是稳定版本
50+
* donate - `17MaxVm9Zm8WQfHrrgA2LVzuEDdSL6AZVN`
51+
4752

4853

callback.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func recent(update *tgbotapi.Update) {
157157
break
158158
}
159159
arr = append(arr, b)
160+
<-time.After(time.Millisecond * 100) // 间隔100毫秒
160161
}
161162

162163
msg.Text += ParseToString("recent", arr)
@@ -357,3 +358,22 @@ func send(msg *tgbotapi.MessageConfig, duration int) {
357358
LoadTemplate(util.Config.StaticPath)
358359
}
359360
}
361+
362+
func addRss(username string) {
363+
chat, err := Bot.TgBot.GetChat(tgbotapi.ChatConfig{
364+
ChatID: 0,
365+
SuperGroupUsername: "@"+username,
366+
})
367+
if err != nil {
368+
return
369+
}
370+
liveMapLock.Lock()
371+
_, ok := liveMap[username]
372+
if ok {
373+
delete(liveMap, username)
374+
} else {
375+
liveMap[username] = chat.ID
376+
}
377+
liveMapLock.Unlock()
378+
}
379+

config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"db_addr": "127.0.0.1:3306",
1313
"db_user": "root",
1414
"db_passwd": "123456",
15-
"db_name": "fkbro"
15+
"db_name": "fkbro",
16+
"rss": ["fkbrolive"]
1617
}

live.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ func look(currency string) { // btc usdc
111111
TomAddr: trans.To.Address,
112112
TomOwner: trans.To.Owner,
113113
}
114-
switch currency {
115-
case "btc":
116-
al.SetURL("https://www.blockchain.com/btc/tx/" + al.Hash)
117-
case "usdt":
118-
al.SetURL("https://www.blockchain.com/eth/tx/0x" + al.Hash)
114+
switch trans.Blockchain {
115+
case "bitcoin":
116+
al.SetURL("https://blockchair.com/zh/bitcoin/transaction/" + al.Hash)
117+
case "ethereum":
118+
al.SetURL("https://blockchair.com/zh/ethereum/transaction/0x" + al.Hash)
119+
case "tron":
120+
al.SetURL("https://tronscan.org/#/transaction/" + al.Hash)
119121
}
120122
Log.Debug(trans)
121123
if trans.From.Owner != trans.To.Owner{ // 双方账户不一样才处理

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func main() {
5151
data.Log.SetLogLevel(ezlog.LogInfo)
5252
WhaleAPI.Logger.SetLogLevel(ezlog.LogInfo)
5353
}
54+
doConfig()
5455

5556
Log.Info("create bot success")
5657

@@ -76,6 +77,12 @@ func main() {
7677
Log.Info("good bye: api query cnt", API.QueryCnt)
7778
}
7879

80+
func doConfig() {
81+
for _, s := range util.Config.Rss {
82+
addRss(s)
83+
}
84+
}
85+
7986
func doSignal() {
8087
sigs := make(chan os.Signal, 1)
8188
signal.Notify(sigs, syscall.SIGINT, syscall.SIGHUP)

static/address.tmp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,4 @@
66
`余额` : `{{.GetBalance}}BTC`
77
`交易次数` : `{{.Tx_count}}`
88
`最后一次交易` : `{{.Last_tx}}`
9-
`详情` : [btc.com](https://btc.com/{{.Address}})
10-
11-
12-
9+
`详情` : [blockchair](https://blockchair.com/zh/bitcoin/address/{{.Address}})

static/block.tmp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
`块大小`: `{{.Size}}B`
77
`时 间 `: `{{GetPastTime .Timestamp}}`
88
`块哈希`: `{{.Hash}}`
9-
`详情 `: [btc.com](https://btc.com/{{.Hash}})
9+
`详情 `: [blockchair](https://blockchair.com/zh/bitcoin/block/{{.Hash}})

static/recent.tmp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
`大小` : `{{.Size}}B`
77
`收益` : `{{.GetReword}}BTC`
88
{{end}}
9-
`详情 `: [btc.com](https://btc.com)
9+
`详情 `: [blockchain](https://www.blockchain.com/zh/explorer)

static/transaction.tmp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
`时间` : `{{GetPastTime .Block_time}}`
99
`输入` : `{{GetBtcValueString .Inputs_value}}BTC` `从{{.Inputs_count}}个地址`
1010
`输出` : `{{GetBtcValueString .Outputs_value}}BTC` `到{{.Outputs_count}}个地址`
11-
`详情 `: [btc.com](https://btc.com/{{.Hash}})
11+
`详情 `: [blockchair](https://blockchair.com/zh/bitcoin/transaction/{{.Hash}})

util/globalobj.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type GlobalObj struct {
2222
DbUser string `json:"db_user"`
2323
DbPasswd string `json:"db_passwd"`
2424
DbName string `json:"db_name"`
25+
Rss []string `json:"rss"` // 提前订阅的用户列表,服务启动自动订阅,不加@
2526
}
2627

2728

0 commit comments

Comments
 (0)