elbekD / kt-telegram-bot

Telegram Bot Library for Kotlin language
MIT License
103 stars 19 forks source link

Can't access chatID and username in group chat #27

Closed moeindev closed 4 years ago

moeindev commented 4 years ago

In my case, I can't access the chat id and usernames in group chats, it gives me null value

elbekD commented 4 years ago

can you please provide more details? code example

moeindev commented 4 years ago

for example, if I send a command in a group chat like this: bot.onCommand("/mycommand") {msg,_ -> val uName = msg.chat.username } the usernme will be null but in the Group chats, but in private chats it's not null!

elbekD commented 4 years ago

docs for Chat object says: username - Optional. Username, for private chats, supergroups and channels if available. username is not available for private groups, so make it public