Old comments removed

This commit is contained in:
ekardnam 2019-07-06 08:26:13 +02:00
parent 0034b21905
commit 73f3cd22c5
2 changed files with 5 additions and 12 deletions

View file

@ -66,12 +66,9 @@ class Bot(val token: String) extends TelegramBot
*/
def fromAdmin(msg: Message): Boolean =
if (fromActualUser(msg) && fromGroup(msg)) {
// it should be an actual user and a message from a group
// check the user member status
// get is safe as fromActualUser is called first
val user = new BotUser(msg.from.get, msg.chat, this)
// if there is an error we cannot now whether the user is an admin or not
// but it's safe in any case to reply as if the user was not an admin
user.isAdmin || user.isCreator
} else {
false
@ -80,12 +77,9 @@ class Bot(val token: String) extends TelegramBot
def canBan(msg: Message): Boolean =
if (fromActualUser(msg) && fromGroup(msg)) {
// it should be an actual user and a message from a group
// check the user member status
// get is safe as fromActualUser is called first
val user = new BotUser(msg.from.get, msg.chat, this)
// if there is an error we cannot now whether the user is an admin or not
// but it's safe in any case to reply as if the user was not an admin
user.canBanUsers
} else {
false

View file

@ -39,13 +39,12 @@ class BotUser(private val user: User, private val chat: Chat, private val bot: B
bot.request(UnbanChatMember(ChatId.fromChat(chat.id), user.id))
}
// lazy attribute initialized on the first successful request
private var chatMember : ChatMember = {
val maxRetryTimes: Int = 10
var chatMember: ChatMember = null
breakable {
for (time <- 0 to maxRetryTimes) {
for (_ <- 0 to maxRetryTimes) {
Await.ready(bot.request(GetChatMember(ChatId.fromChat(chat.id), user.id)), Duration.Inf).value.get match {
case Success(cm) => {
chatMember = cm