Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions spam/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ def __init__(self, mongo_url) -> None:
self.sibyl = MongoClient(self.db_url)['Sibyl']['SIBYLMODE']

def is_vanitas(self, chat_id: int) -> bool:
x = self.vanitas.find_one({"chat_id": chat_id})
if x:
return True
return False
return bool(x := self.vanitas.find_one({"chat_id": chat_id}))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DB.is_vanitas refactored with the following changes:


def set_vanitas(self, chat_id: int):
set_vanitas = self.is_vanitas(chat_id)
if set_vanitas:
if set_vanitas := self.is_vanitas(chat_id):
Comment on lines -22 to +19
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DB.set_vanitas refactored with the following changes:

return
return self.vanitas.insert_one({"chat_id": chat_id})

Expand All @@ -32,14 +28,10 @@ def rm_vanitas(self, chat_id: int):


def is_sibyl(self, chat_id: int) -> bool:
x = self.sibyl.find_one({"chat_id": chat_id})
if x:
return True
return False
return bool(x := self.sibyl.find_one({"chat_id": chat_id}))
Comment on lines -35 to +31
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DB.is_sibyl refactored with the following changes:


def set_sibyl(self, chat_id: int):
set_sibyl = self.is_sibyl(chat_id)
if set_sibyl:
if set_sibyl := self.is_sibyl(chat_id):
Comment on lines -41 to +34
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DB.set_sibyl refactored with the following changes:

return
return self.sibyl.insert_one({"chat_id": chat_id})

Expand Down
4 changes: 2 additions & 2 deletions spam/helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

def is_vanitasalert(user):
res = get("https://vanitas-api.up.railway.app/user/" + str(user)).json()
return True if res['blacklisted'] else False
return bool(res['blacklisted'])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function is_vanitasalert refactored with the following changes:



def is_sibylalert(user):
res = get("https://psychopass.animekaizoku.com/getInfo?token=5086015489:N0tFM9DsvPD-bjlvHx57KFqJuSS5-AmJIMsuqgidgSWd9hm7W1Zs-hdPhUAjn3U-&user-id=" + str(user)).json()
return True if res['success'] else False
return bool(res['success'])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function is_sibylalert refactored with the following changes:




Expand Down
11 changes: 4 additions & 7 deletions spam/modules/sibyl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
async def sibylalert(_, message):
if is_admin(message.chat.id, message.from_user.id):
return
is_sibyl = db.is_sibyl(message.chat.id)
if not is_sibyl:
db.set_sibyl(message.chat.id)
await message.reply_text("Sibyl Alert Enable")
else:
if is_sibyl := db.is_sibyl(message.chat.id):
db.rm_sibyl(message.chat.id)
await message.reply_text("Sibyl Alert Disable")
Comment on lines -20 to 26
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function sibylalert refactored with the following changes:

else:
db.set_sibyl(message.chat.id)
await message.reply_text("Sibyl Alert Enable")


@bot.on_message(filters.new_chat_members)
Expand Down Expand Up @@ -52,5 +51,3 @@ def salert(_, m: Message):
callback_data=f"mute:mute:{user}")
],
]))
else:
pass
Comment on lines -55 to -56
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function salert refactored with the following changes:

5 changes: 1 addition & 4 deletions spam/modules/spam.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
def is_admin(group_id: int, user_id: int):
try:
user_data = bot.get_chat_member(group_id, user_id)
if user_data.status == 'administrator' or user_data.status == 'creator':
return True
else:
return False
return user_data.status in ['administrator', 'creator']
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function is_admin refactored with the following changes:

except:
return False

Expand Down
11 changes: 4 additions & 7 deletions spam/modules/vanitas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
async def vanitasalert(_, message):
if is_admin(message.chat.id, message.from_user.id):
return
is_vanitas = db.is_vanitas(message.chat.id)
if not is_vanitas:
db.set_vanitas(message.chat.id)
await message.reply_text("Alert Mode Enable")
else:
if is_vanitas := db.is_vanitas(message.chat.id):
db.rm_vanitas(message.chat.id)
await message.reply_text("Alert Mode Disable")
Comment on lines -20 to 26
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function vanitasalert refactored with the following changes:

else:
db.set_vanitas(message.chat.id)
await message.reply_text("Alert Mode Enable")


@bot.on_message(filters.new_chat_members)
Expand Down Expand Up @@ -52,5 +51,3 @@ def valert(_, m: Message):
callback_data=f"mute:mute:{user}")
],
]))
else:
pass
Comment on lines -55 to -56
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function valert refactored with the following changes: