mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 19:24:23 +00:00
Update to version 6.0.3
This commit is contained in:
@@ -2,6 +2,8 @@ from re import findall
|
||||
from typing import Union, Literal, TYPE_CHECKING
|
||||
from dataclasses import asdict
|
||||
|
||||
from core.classes import user
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.definition import MChannel
|
||||
from core.base import Base
|
||||
@@ -31,6 +33,10 @@ class Channel:
|
||||
result = False
|
||||
exist = False
|
||||
|
||||
if not self.Is_Channel(newChan.name):
|
||||
self.Logs.error(f"The channel {newChan.name} is not valid, channel must start with #")
|
||||
return False
|
||||
|
||||
for record in self.UID_CHANNEL_DB:
|
||||
if record.name.lower() == newChan.name.lower():
|
||||
# If the channel exist, update the user list and do not go further
|
||||
@@ -129,6 +135,29 @@ class Channel:
|
||||
except Exception as err:
|
||||
self.Logs.error(f'{err}')
|
||||
|
||||
def is_user_present_in_channel(self, channel_name: str, uid: str) -> bool:
|
||||
"""Check if a user is present in the channel
|
||||
|
||||
Args:
|
||||
channel_name (str): The channel to check
|
||||
uid (str): The UID
|
||||
|
||||
Returns:
|
||||
bool: True if the user is present in the channel
|
||||
"""
|
||||
user_found = False
|
||||
chan = self.get_Channel(channel_name=channel_name)
|
||||
if chan is None:
|
||||
return user_found
|
||||
|
||||
clean_uid = self.Base.clean_uid(uid=uid)
|
||||
for chan_uid in chan.uids:
|
||||
if self.Base.clean_uid(chan_uid) == clean_uid:
|
||||
user_found = True
|
||||
break
|
||||
|
||||
return user_found
|
||||
|
||||
def clean_channel(self) -> None:
|
||||
"""Remove Channels if empty
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user