File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
BusinessConnectionsBot/src/main/kotlin Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.extensions.api.answers.answer
66import dev.inmo.tgbotapi.extensions.api.bot.getMe
77import dev.inmo.tgbotapi.extensions.api.business.deleteBusinessMessages
88import dev.inmo.tgbotapi.extensions.api.business.readBusinessMessage
9+ import dev.inmo.tgbotapi.extensions.api.business.setBusinessAccountName
910import dev.inmo.tgbotapi.extensions.api.chat.modify.pinChatMessage
1011import dev.inmo.tgbotapi.extensions.api.chat.modify.unpinChatMessage
1112import dev.inmo.tgbotapi.extensions.api.get.getBusinessConnection
@@ -169,5 +170,24 @@ suspend fun main(args: Array<String>) {
169170 }
170171 )
171172 }
173+ onCommandWithArgs(" set_business_account_name" , initialFilter = { it.chat is PrivateChat }) { it, args ->
174+ val firstName = args[0 ]
175+ val secondName = args.getOrNull(1 )
176+ val businessConnectionId = chatsBusinessConnections[it.chat.id] ? : return @onCommandWithArgs
177+ val set = runCatching {
178+ setBusinessAccountName(
179+ businessConnectionId,
180+ firstName,
181+ secondName
182+ )
183+ }.getOrElse { false }
184+ reply(it) {
185+ if (set) {
186+ + " Account name has been set"
187+ } else {
188+ + " Account name has not been set"
189+ }
190+ }
191+ }
172192 }.second.join()
173193}
You can’t perform that action at this time.
0 commit comments