-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (45 loc) · 1.06 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
package main
import (
"log"
"time"
"maunium.net/go/mautrix"
)
func main() {
var c Config
c.getConf()
// fmt.Println(c)
if c.Blacklist.Active && c.Whitelist.Active {
log.Fatal("Only one of blacklist or whitelist can be active")
}
log.Println("Getting IP")
IP := GetIPAddress()
if IP == "" {
log.Println("Could not get IP, trying again in 5 seconds")
time.Sleep(time.Second * 5)
IP = GetIPAddress()
if IP == "" {
log.Fatal("Could not get IP")
}
}
log.Println("IP of the LaMetic Time:", IP)
l := LaMetric{
IP: IP,
}
l.Api_Key = l.EncodeApiKey(c.Api_Key)
log.Println("Logging into", c.Homeserver, "as", c.Username)
client, err := mautrix.NewClient(c.Homeserver, "", "")
if err != nil {
panic(err)
}
_, err = client.Login(&mautrix.ReqLogin{
Type: "m.login.password",
Identifier: mautrix.UserIdentifier{Type: mautrix.IdentifierTypeUser, User: c.Username},
Password: c.Password,
StoreCredentials: true,
})
if err != nil {
panic(err)
}
log.Println("Login successful")
bridge_messages(l, client, c)
}