package main

import (
	"github.com/matrix-org/gomatrix"
	"log"
)

func main() {
	// 配置变量
	homeserver := "https://bridge.usami.space"
	username := "gptbot"
	password := "aaaaaaaa"
	displayName := "山吹爱丽丝"

	// 创建 Matrix 客户端
	client, err := gomatrix.NewClient(homeserver, "", "")
	if err != nil {
		log.Fatalf("创建 Matrix 客户端失败: %v", err)
	}

	// 登录到 Matrix
	resp, err := client.Login(&gomatrix.ReqLogin{
		Type:     "m.login.password",
		User:     username,
		Password: password,
	})
	if err != nil {
		log.Fatalf("登录失败: %v", err)
	}

	client.SetCredentials(resp.UserID, resp.AccessToken)

	// 设置显示名称
	if err := client.SetDisplayName(displayName); err != nil {
		log.Fatalf("设置显示名称失败: %v", err)
	}

	log.Println("机器人资料更新成功")
}
