TheHamkerCat 5 лет назад
Родитель
Сommit
26d27f5354
2 измененных файлов с 11 добавлено и 4 удалено
  1. 2 0
      wbb/modules/info.py
  2. 9 4
      wbb/modules/karma.py

+ 2 - 0
wbb/modules/info.py

@@ -16,6 +16,8 @@ __HELP__ = """
 
 
 async def get_user_info(user):
 async def get_user_info(user):
     user = await app.get_users(user)
     user = await app.get_users(user)
+    if not user.first_name:
+        return ["Deleted account", None]
     user_id = user.id
     user_id = user.id
     username = user.username
     username = user.username
     first_name = user.first_name
     first_name = user.first_name

+ 9 - 4
wbb/modules/karma.py

@@ -21,6 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 SOFTWARE.
 """
 """
+import asyncio
+
 from pyrogram import filters
 from pyrogram import filters
 
 
 from wbb import app
 from wbb import app
@@ -128,8 +130,8 @@ async def downvote(_, message):
 @capture_err
 @capture_err
 async def karma(_, message):
 async def karma(_, message):
     chat_id = message.chat.id
     chat_id = message.chat.id
-
     if not message.reply_to_message:
     if not message.reply_to_message:
+        m = await message.reply_text("Analyzing Karma...Will Take 20 Seconds")
         karma = await get_karmas(chat_id)
         karma = await get_karmas(chat_id)
         msg = f"**Karma list of {message.chat.title}:- **\n"
         msg = f"**Karma list of {message.chat.title}:- **\n"
         limit = 0
         limit = 0
@@ -144,20 +146,23 @@ async def karma(_, message):
                 )
                 )
             )
             )
         if not karma_arranged:
         if not karma_arranged:
-            await message.reply_text("No karma in DB for this chat.")
+            await m.edit("No karma in DB for this chat.")
             return
             return
         for user_idd, karma_count in karma_arranged.items():
         for user_idd, karma_count in karma_arranged.items():
             if limit > 9:
             if limit > 9:
                 break
                 break
             try:
             try:
                 user = await app.get_users(int(user_idd))
                 user = await app.get_users(int(user_idd))
+                await asyncio.sleep(2)
             except Exception:
             except Exception:
                 continue
                 continue
             first_name = user.first_name
             first_name = user.first_name
+            if not first_name:
+                continue
             username = user.username
             username = user.username
-            msg += f"{first_name} [{username if username else ''} `{user_idd}`]: `{karma_count}`\n"
+            msg += f"**{karma_count}**  {(first_name[0:12] + '...') if len(first_name) > 12 else first_name}  `{('@' + username) if username else user_idd}`\n"
             limit += 1
             limit += 1
-        await message.reply_text(msg)
+        await m.edit(msg)
     else:
     else:
         user_id = message.reply_to_message.from_user.id
         user_id = message.reply_to_message.from_user.id
         karma = await get_karma(chat_id, await int_to_alpha(user_id))
         karma = await get_karma(chat_id, await int_to_alpha(user_id))