-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
66 lines (53 loc) · 1.52 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/yanzay/tbot"
)
var apikey, apisecret, signkey string
func main() {
bot, err := tbot.NewServer(os.Getenv("TELEGRAM_TOKEN"))
if err != nil {
log.Fatal(err)
}
bot.HandleFunc("/api {key}", keyHandler)
bot.HandleFunc("/secret {key}", secretHandler)
bot.HandleFunc("/hi", HiHandler)
bot.HandleFunc("/balance", balanceHandler)
bot.HandleFunc("/withdraw {currency} {quantity} {address}", withdrawHandler)
bot.HandleFunc("/tradebuy {market} {rate} {quantity}", tradeBuyHandler)
bot.HandleFunc("/tradesell {market} {rate} {quantity}", tradeSellHandler)
bot.ListenAndServe()
}
func HiHandler(message *tbot.Message) {
// Handler can reply with several messages
message.Replyf("Hello, %s!", message.From.FirstName)
time.Sleep(1 * time.Second)
message.Reply("What's up?")
time.Sleep(1 * time.Second)
message.Reply("Type /help to see my available commands.")
}
func keyHandler(m *tbot.Message) {
// m.Vars contains all variables, parsed during routing
apikey = m.Vars["key"]
fmt.Println(apikey)
// Convert string variable to integer seconds value
// seconds, err := strconv.Atoi(apikey)
// if err != nil {
// m.Reply("Invalid API Key")
// return
// }
}
func secretHandler(m *tbot.Message) {
// m.Vars contains all variables, parsed during routing
apisecret = m.Vars["key"]
fmt.Println(apisecret)
// Convert string variable to integer seconds value
// seconds, err := strconv.Atoi(apikey)
// if err != nil {
// m.Reply("Invalid API Key")
// return
// }
}