소스 검색

Old comments removed

ekardnam 4 년 전
부모
커밋
73f3cd22c5
2개의 변경된 파일5개의 추가작업 그리고 12개의 파일을 삭제
  1. 4 10
      src/main/scala/org/congressodeiradicali/karlmarx/Bot.scala
  2. 1 2
      src/main/scala/org/congressodeiradicali/karlmarx/BotUser.scala

+ 4 - 10
src/main/scala/org/congressodeiradicali/karlmarx/Bot.scala

@@ -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

+ 1 - 2
src/main/scala/org/congressodeiradicali/karlmarx/BotUser.scala

@@ -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