forked from sihuan/qqtg-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (34 loc) · 880 Bytes
/
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
package main
import (
"github.com/sihuan/qqtg-bridge/cache"
"github.com/sihuan/qqtg-bridge/config"
"github.com/sihuan/qqtg-bridge/message"
"github.com/sihuan/qqtg-bridge/qq"
"github.com/sihuan/qqtg-bridge/tg"
"os"
"os/signal"
)
func main() {
//os.Setenv("HTTP_PROXY", "127.0.0.1:8889")
//os.Setenv("HTTPS_PROXY", "127.0.0.1:8889")
config.Init()
cache.Init()
qq.Init()
qq.Login()
qq.RefreshList()
qq.MakeChan()
qq.StartService()
tg.Init()
tg.MakeChan()
go tg.StartService()
forward := func(chatChanA message.MsgChan, chatChanB message.MsgChan) {
go message.Copy(chatChanA, chatChanB)
go message.Copy(chatChanB, chatChanA)
}
for _, forwardConfig := range config.GlobalConfig.Forwards {
forward(qq.Instance.Chats[forwardConfig.QQ], tg.Instance.Chats[forwardConfig.TG])
}
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt)
<-sig
}