Skip to content

Commit eb82a0a

Browse files
committed
Print bot username or user ID on startup in Example.java.
1 parent 44c0053 commit eb82a0a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

example/src/main/java/it/tdlight/example/Example.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,15 @@ public static void main(String[] args) throws Exception {
7474

7575
// Create and start the client
7676
try (var app = new ExampleApp(clientBuilder, authenticationData, adminId)) {
77-
// Get me
78-
TdApi.User me = app.getClient().getMeAsync().get(1, TimeUnit.MINUTES);
77+
// Get me
78+
TdApi.User me = app.getClient().getMeAsync().get(1, TimeUnit.MINUTES);
79+
80+
// Print the bot username so the user knows where to write
81+
if (me.usernames != null && me.usernames.activeUsernames.length > 0) {
82+
System.out.println("Bot ready! Send messages to: @" + me.usernames.activeUsernames[0]);
83+
} else {
84+
System.out.println("Bot ready! User ID: " + me.id);
85+
}
7986

8087
// Create the "saved messages" chat
8188
var savedMessagesChat = app.getClient().send(new CreatePrivateChat(me.id, true)).get(1, TimeUnit.MINUTES);

0 commit comments

Comments
 (0)