@@ -14,28 +14,30 @@ import (
1414func help (update * tgbotapi.Update ) {
1515 Log .Debug ("recv msg:" , update .Message .Text , "chatID:" , update .Message .Chat .ID )
1616 msg := tgbotapi .NewMessage (update .Message .Chat .ID , "" )
17- msg .Text = ParseToString ("help" , nil )
17+ msg .Text = "@" + update .Message .From .UserName + " - " + update .Message .From .FirstName + "\n "
18+ msg .Text += ParseToString ("help" , nil )
1819 msg .ParseMode = "Markdown"
1920 send (& msg , 5 )
2021}
2122
2223func newest (update * tgbotapi.Update ) {
2324 Log .Debug ("recv msg:" , update .Message .Text , "chatID:" , update .Message .Chat .ID )
2425 msg := tgbotapi .NewMessage (update .Message .Chat .ID , "" )
25-
26+ msg . Text = "@" + update . Message . From . UserName + " - " + update . Message . From . FirstName + " \n "
2627 block , err := getNewestBlock ()
2728 if err != nil {
2829 Log .Error ("GetBlockInfo:" , err )
2930 return
3031 }
31- msg .Text = ParseToString ("block" , block )
32+ msg .Text + = ParseToString ("block" , block )
3233 msg .ParseMode = "Markdown"
3334 send (& msg , 5 )
3435}
3536
3637func recent (update * tgbotapi.Update ) {
3738 Log .Debug ("recv msg:" , update .Message .Text , "chatID:" , update .Message .Chat .ID )
3839 msg := tgbotapi .NewMessage (update .Message .Chat .ID , "" )
40+ msg .Text = "@" + update .Message .From .UserName + " - " + update .Message .From .FirstName + "\n "
3941 msg .ParseMode = "Markdown"
4042
4143 arr := make ([]* btcinfo.Block , 0 )
@@ -55,13 +57,14 @@ func recent(update *tgbotapi.Update) {
5557 arr = append (arr , b )
5658 }
5759
58- msg .Text = ParseToString ("recent" , arr )
60+ msg .Text + = ParseToString ("recent" , arr )
5961 send (& msg , 5 )
6062}
6163
6264func q (update * tgbotapi.Update ) {
6365 Log .Debug ("recv msg:" , update .Message .Text , "chatID:" , update .Message .Chat .ID )
6466 msg := tgbotapi .NewMessage (update .Message .Chat .ID , "" )
67+ msg .Text = "@" + update .Message .From .UserName + " - " + update .Message .From .FirstName + "\n "
6568 msg .ParseMode = "Markdown"
6669 fields := strings .Fields (update .Message .Text )
6770 var want string
@@ -86,13 +89,13 @@ func q(update *tgbotapi.Update) {
8689 }
8790 if len (want ) < 20 || strings .HasPrefix (want , "000000" ) { // block 块
8891 iface , err = API .GetBlockInfo (want )
89- msg .Text = ParseToString ("block" , iface )
92+ msg .Text + = ParseToString ("block" , iface )
9093 } else if len (want ) > 20 && len (want ) < 40 { // address 地址
9194 iface , err = API .GetAddressInfo (want )
92- msg .Text = ParseToString ("address" , iface )
95+ msg .Text + = ParseToString ("address" , iface )
9396 } else if len (want ) == 64 { // transaction 交易
9497 iface , err = API .GetTransactionInfo (want )
95- msg .Text = ParseToString ("transaction" , iface )
98+ msg .Text + = ParseToString ("transaction" , iface )
9699 } else {
97100 return
98101 }
@@ -103,6 +106,20 @@ func q(update *tgbotapi.Update) {
103106 send (& msg , 5 )
104107}
105108
109+ func quotes (update * tgbotapi.Update ) {
110+ Log .Debug ("recv msg:" , update .Message .Text , "chatID:" , update .Message .Chat .ID )
111+ msg := tgbotapi .NewMessage (update .Message .Chat .ID , "" )
112+ msg .Text = "@" + update .Message .From .UserName + " - " + update .Message .From .FirstName + "\n "
113+ msg .ParseMode = "Markdown"
114+
115+ klines , err := HuobiAPI .GetKLine ("btcusdt" , "60min" , 1 )
116+ if err != nil {
117+ return
118+ }
119+ msg .Text += ParseToString ("quotes" , klines [0 ])
120+ send (& msg , 5 )
121+ }
122+
106123func unknow (update * tgbotapi.Update ) {
107124 q (update )
108125}
@@ -138,7 +155,7 @@ func send(msg *tgbotapi.MessageConfig, duration int) {
138155 for ; cnt > 0 ; cnt -- {
139156 _ , err := Bot .TgBot .Send (msg )
140157 if err != nil {
141- Log .Debug ("send msg:" , err , " will retry..." , cnt )
158+ Log .Debug ("send msg:" , err , " will retry..." , cnt - 1 )
142159 <- time .After (time .Duration (duration )* time .Second )
143160 } else {
144161 break
0 commit comments