From 5cb8226775d28bb35dc7da1fbb997523e8f047e8 Mon Sep 17 00:00:00 2001 From: Steven Date: Sat, 18 May 2024 10:59:20 +0800 Subject: [PATCH] chore: add server start logs --- .env.example | 2 +- README.md | 5 ++++- client.go | 18 ++++++++++-------- memogram.go | 7 +++++++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index 59c86d4..72d17c3 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,2 @@ -SERVER_ADDR=demo.usememos.com +SERVER_ADDR=dns:localhost:5230 BOT_TOKEN=your_bot_token \ No newline at end of file diff --git a/README.md b/README.md index 7631514..0d0df0b 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,13 @@ Download the binary files for your operating system from the [Releases](https:// Create a `.env` file in the project's root directory and add the following configuration: ```env -SERVER_ADDR=your_memos_server_address (e.g., https://demo.usememos.com) +SERVER_ADDR=dns:localhost:5230 BOT_TOKEN=your_telegram_bot_token ``` +The `SERVER_ADDR` should be a gRPC server address that the Memos is running on. It follows the [gRPC Name Resolution +](https://github.com/grpc/grpc/blob/master/doc/naming.md). + ## Usage ### Starting the Service diff --git a/client.go b/client.go index 6456306..3eec4f8 100644 --- a/client.go +++ b/client.go @@ -6,17 +6,19 @@ import ( ) type MemosClient struct { - AuthService v1pb.AuthServiceClient - UserService v1pb.UserServiceClient - MemoService v1pb.MemoServiceClient - ResourceService v1pb.ResourceServiceClient + WorkspaceService v1pb.WorkspaceServiceClient + AuthService v1pb.AuthServiceClient + UserService v1pb.UserServiceClient + MemoService v1pb.MemoServiceClient + ResourceService v1pb.ResourceServiceClient } func NewMemosClient(conn *grpc.ClientConn) *MemosClient { return &MemosClient{ - AuthService: v1pb.NewAuthServiceClient(conn), - UserService: v1pb.NewUserServiceClient(conn), - MemoService: v1pb.NewMemoServiceClient(conn), - ResourceService: v1pb.NewResourceServiceClient(conn), + WorkspaceService: v1pb.NewWorkspaceServiceClient(conn), + AuthService: v1pb.NewAuthServiceClient(conn), + UserService: v1pb.NewUserServiceClient(conn), + MemoService: v1pb.NewMemoServiceClient(conn), + ResourceService: v1pb.NewResourceServiceClient(conn), } } diff --git a/memogram.go b/memogram.go index f81cb2e..bad856f 100644 --- a/memogram.go +++ b/memogram.go @@ -64,6 +64,13 @@ func NewService() (*Service, error) { func (s *Service) Start(ctx context.Context) { slog.Info("Memogram started") + // Try to get workspace profile. + workspaceProfile, err := s.client.WorkspaceService.GetWorkspaceProfile(ctx, &v1pb.GetWorkspaceProfileRequest{}) + if err != nil { + slog.Error("failed to get workspace profile", slog.Any("err", err)) + return + } + slog.Info("workspace profile", slog.Any("profile", workspaceProfile)) s.bot.Start(ctx) }