Bug fixes and small structural changes #7
24
classes/errors/holo_user.py
Normal file
24
classes/errors/holo_user.py
Normal file
@ -0,0 +1,24 @@
|
||||
"""Exceptions that are meant to be used by HoloUser class
|
||||
and other modules that handle those exceptions"""
|
||||
|
||||
class UserNotFoundError(Exception):
|
||||
"""HoloUser could not find user with such an ID in database"""
|
||||
def __init__(self, user, user_id):
|
||||
self.user = user
|
||||
self.user_id = user_id
|
||||
super().__init__(f"User of type {type(self.user)} with id {self.user_id} was not found")
|
||||
|
||||
class UserInvalidError(Exception):
|
||||
"""Provided to HoloUser object is not supported"""
|
||||
def __init__(self, user):
|
||||
self.user = user
|
||||
super().__init__(f"Could not find HoloUser by using {type(self.user)} as an input type")
|
||||
|
||||
class LabelTooLongError(Exception):
|
||||
def __init__(self, label: str) -> None:
|
||||
self.label = label
|
||||
super().__init__(f"Could not set label to '{label}' because it is {len(label)} characters long (16 is maximum)")
|
||||
|
||||
class LabelSettingError(Exception):
|
||||
def __init__(self, exp: Exception, trace: str) -> None:
|
||||
super().__init__(f"❌ **Could not set label**\n\nException: `{exp}`\n\n**Traceback:**\n```\n{trace}\n```")
|
@ -6,6 +6,7 @@ from pyrogram.types import User, ChatMember, ChatPrivileges, Chat, Message, Phot
|
||||
from pyrogram.errors import bad_request_400
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from classes.errors.geo import PlaceNotFoundError
|
||||
from classes.errors.holo_user import UserInvalidError, UserNotFoundError, LabelTooLongError, LabelSettingError
|
||||
from modules.database import col_tmp, col_users, col_applications, col_sponsorships, col_messages, col_spoilers
|
||||
from modules.logging import logWrite
|
||||
from modules.utils import configGet, find_location, locale, should_quote
|
||||
@ -53,28 +54,6 @@ class DefaultSponsorshipTemp(dict):
|
||||
}
|
||||
}
|
||||
|
||||
class UserNotFoundError(Exception):
|
||||
"""HoloUser could not find user with such an ID in database"""
|
||||
def __init__(self, user, user_id):
|
||||
self.user = user
|
||||
self.user_id = user_id
|
||||
super().__init__(f"User of type {type(self.user)} with id {self.user_id} was not found")
|
||||
|
||||
class UserInvalidError(Exception):
|
||||
"""Provided to HoloUser object is not supported"""
|
||||
def __init__(self, user):
|
||||
self.user = user
|
||||
super().__init__(f"Could not find HoloUser by using {type(self.user)} as an input type")
|
||||
|
||||
class LabelTooLongError(Exception):
|
||||
def __init__(self, label: str) -> None:
|
||||
self.label = label
|
||||
super().__init__(f"Could not set label to '{label}' because it is {len(label)} characters long (16 is maximum)")
|
||||
|
||||
class LabelSettingError(Exception):
|
||||
def __init__(self, exp: Exception, trace: str) -> None:
|
||||
super().__init__(f"❌ **Could not set label**\n\nException: `{exp}`\n\n**Traceback:**\n```\n{trace}\n```")
|
||||
|
||||
class HoloUser():
|
||||
"""This object represents a user of HoloChecker bot.
|
||||
It is primarily used to interact with a database in a more python-friendly way,
|
||||
|
@ -3,7 +3,8 @@ from app import app
|
||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply, CallbackQuery
|
||||
from pyrogram.client import Client
|
||||
from pyrogram import filters
|
||||
from classes.holo_user import HoloUser, LabelSettingError
|
||||
from classes.errors.holo_user import LabelSettingError
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import configGet, locale, logWrite, should_quote
|
||||
from modules.database import col_tmp, col_sponsorships
|
||||
|
||||
|
@ -5,7 +5,8 @@ from pyrogram.enums.parse_mode import ParseMode
|
||||
from pyrogram.types import Message
|
||||
from pyrogram.errors import bad_request_400
|
||||
from pyrogram.client import Client
|
||||
from classes.holo_user import HoloUser, UserNotFoundError
|
||||
from classes.errors.holo_user import UserNotFoundError
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import logWrite, locale, should_quote
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from modules.database import col_applications
|
||||
|
@ -5,7 +5,8 @@ from pyrogram.types import Message
|
||||
from pyrogram.client import Client
|
||||
from pyrogram.errors import bad_request_400
|
||||
from pyrogram.enums.chat_action import ChatAction
|
||||
from classes.holo_user import HoloUser, UserNotFoundError, UserInvalidError
|
||||
from classes.errors.holo_user import UserNotFoundError, UserInvalidError
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import jsonLoad, should_quote, logWrite, locale, download_tmp, create_tmp, find_user
|
||||
from modules import custom_filters
|
||||
|
||||
|
@ -3,7 +3,8 @@ from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
from pyrogram.client import Client
|
||||
from modules.utils import configGet, locale, should_quote, find_user
|
||||
from classes.holo_user import HoloUser, LabelTooLongError, LabelSettingError
|
||||
from classes.errors.holo_user import LabelTooLongError, LabelSettingError
|
||||
from classes.holo_user import HoloUser
|
||||
from modules import custom_filters
|
||||
|
||||
# Label command ================================================================================================================
|
||||
|
@ -2,7 +2,8 @@ from app import app
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
from pyrogram.client import Client
|
||||
from classes.holo_user import HoloUser, UserInvalidError
|
||||
from classes.errors.holo_user import UserInvalidError
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import logWrite, locale, should_quote, find_user
|
||||
from modules import custom_filters
|
||||
|
||||
|
@ -2,7 +2,8 @@ from app import app
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import Message, ReplyKeyboardMarkup
|
||||
from pyrogram.client import Client
|
||||
from classes.holo_user import HoloUser, UserInvalidError, UserNotFoundError
|
||||
from classes.errors.holo_user import UserNotFoundError, UserInvalidError
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.logging import logWrite
|
||||
from modules.utils import locale
|
||||
from modules.database import col_spoilers
|
||||
|
@ -9,7 +9,8 @@ from pyrogram.client import Client
|
||||
from pyrogram.enums.chat_type import ChatType
|
||||
from pyrogram.enums.chat_members_filter import ChatMembersFilter
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from classes.holo_user import HoloUser, UserInvalidError, UserNotFoundError
|
||||
from classes.errors.holo_user import UserNotFoundError, UserInvalidError
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import configGet, locale
|
||||
from modules.database import col_applications, col_spoilers
|
||||
from bson.objectid import ObjectId
|
||||
|
Reference in New Issue
Block a user