1
0
mirror of https://github.com/pinpox/gitea-matrix-bot synced 2024-11-22 19:31:58 +01:00
gitea-matrix-bot/main.go

79 lines
1.4 KiB
Go
Raw Normal View History

2019-04-13 12:31:28 +02:00
package main
import (
"fmt"
"github.com/go-ini/ini"
"os"
_ "github.com/matrix-org/gomatrix"
)
// import "net/http"
//TODO get this vals from config file
// var (
// flagPort is the open port the application listens on
// flagPort = flag.String("port", "9000", "Port to listen on")
// matrixPass = "oSaiNahqu5ahF5jieBe2UKok"
// matrixUser = "reminder-bot"
// matrixHost = "http://matrix.org"
// postURI = "/post"
// )
var cfg *ini.File
var err error
func init() {
cfg, err = ini.Load("config.ini")
if err != nil {
fmt.Printf("Fail to read file: %v", err)
os.Exit(1)
}
}
func main() {
//TODO Check if already logged in
//TODO Check if In room
//TODO Send
// fmt.Println("Logging in")
// cli, _ := gomatrix.NewClient("http://matrix.org", "", "")
// resp, err := cli.Login(&gomatrix.ReqLogin{
// Type: "m.login.password",
// User: matrixUser,
// Password: matrixPass,
// })
// if err != nil {
// panic(err)
// }
// cli.SetCredentials(resp.UserID, resp.AccessToken)
// fmt.Println("Joining Room")
// roomID := ""
// if resp, err := cli.JoinRoom("#test-reminder-bot:matrix.org", "", nil); err != nil {
// panic(err)
// } else {
// roomID = resp.RoomID
// }
// fmt.Println("Sending a message")
// _, err = cli.SendText(roomID, "test message 0")
// if err != nil {
// panic(err)
// }
fmt.Println("Setting up POST-listener")
setupListener()
}