As another solution you can use something like TDLib to make a robotic client.
I prefer Kotlin, so made a small example with this lib
https://github.com/KurenaiRyu/tdlight-sdk (This is just for example of using similar clients, not my recommendation)
Код:
Скопировать в буфер обмена
import io.github.kurenairyu.tdlight.Client
import io.github.kurenairyu.tdlight.exception.ClientException
import io.github.kurenairyu.tdlight.handler.UpdateHandler
import io.github.kurenairyu.tdlight.util.ResultHandler
import io.github.kurenairyu.tdlight.util.TelegramObject
import io.github.kurenairyu.tdlight.util.TdApi
class Bot(token: String = "YOUR_TOKEN") {
private val client = Client.create(token)
fun init() {
client.start()
}
fun sendDirectMessagesToFriends(message: String) {
client.send(TdApi.GetContacts(), object : ResultHandler {
override fun onResult(obj: TelegramObject) {
if (obj is TdApi.Users) {
obj.users.filterIsInstance<TdApi.User>().forEach { user ->
if (user.type.constructor == TdApi.UserTypeBot.CONSTRUCTOR) {
//Ignore bots
return@forEach
}
client.send(TdApi.SendMessage(user.id, 0, false, false, null, TdApi.InputMessageText(TdApi.FormattedText(message, null), false, true)))
}
}
}
})
}
}