-
Notifications
You must be signed in to change notification settings - Fork 5
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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})) | ||
|
|
||
| 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return | ||
| return self.vanitas.insert_one({"chat_id": chat_id}) | ||
|
|
||
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return | ||
| return self.sibyl.insert_one({"chat_id": chat_id}) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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']) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| 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']) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| db.set_sibyl(message.chat.id) | ||
| await message.reply_text("Sibyl Alert Enable") | ||
|
|
||
|
|
||
| @bot.on_message(filters.new_chat_members) | ||
|
|
@@ -52,5 +51,3 @@ def salert(_, m: Message): | |
| callback_data=f"mute:mute:{user}") | ||
| ], | ||
| ])) | ||
| else: | ||
| pass | ||
|
Comment on lines
-55
to
-56
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| except: | ||
| return False | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| db.set_vanitas(message.chat.id) | ||
| await message.reply_text("Alert Mode Enable") | ||
|
|
||
|
|
||
| @bot.on_message(filters.new_chat_members) | ||
|
|
@@ -52,5 +51,3 @@ def valert(_, m: Message): | |
| callback_data=f"mute:mute:{user}") | ||
| ], | ||
| ])) | ||
| else: | ||
| pass | ||
|
Comment on lines
-55
to
-56
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
DB.is_vanitasrefactored with the following changes:boolean-if-exp-identity)reintroduce-else)assign-if-exp)use-named-expression)