mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 19:24:23 +00:00
Adding a method to test a channel
This commit is contained in:
26
core/base.py
26
core/base.py
@@ -509,8 +509,34 @@ class Base:
|
|||||||
self.periodic_func.clear()
|
self.periodic_func.clear()
|
||||||
|
|
||||||
def clean_uid(self, uid:str) -> str:
|
def clean_uid(self, uid:str) -> str:
|
||||||
|
"""Clean UID by removing @ / % / + / Owner / and *
|
||||||
|
|
||||||
|
Args:
|
||||||
|
uid (str): The UID to clean
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: Clean UID without any sign
|
||||||
|
"""
|
||||||
|
|
||||||
pattern = fr'[@|%|\+|~|\*]*'
|
pattern = fr'[@|%|\+|~|\*]*'
|
||||||
parsed_UID = re.sub(pattern, '', uid)
|
parsed_UID = re.sub(pattern, '', uid)
|
||||||
|
|
||||||
return parsed_UID
|
return parsed_UID
|
||||||
|
|
||||||
|
def Is_Channel(self, channelToCheck: str) -> bool:
|
||||||
|
"""Check if the string has the # caractere and return True if this is a channel
|
||||||
|
|
||||||
|
Args:
|
||||||
|
channelToCheck (str): The string to test if it is a channel or not
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if the string is a channel / False if this is not a channel
|
||||||
|
"""
|
||||||
|
|
||||||
|
pattern = fr'^#'
|
||||||
|
isChannel = re.findall(pattern, channelToCheck)
|
||||||
|
|
||||||
|
if not isChannel:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
Reference in New Issue
Block a user