mirror of
https://github.com/nichkara/InfinitumBotty.git
synced 2026-06-10 22:26:23 +02:00
require .icd to resolve ICD10 codes and limit answer to at most 5
This commit is contained in:
@@ -21,17 +21,18 @@ class ICDObserver(PrivMsgObserverPrototype):
|
||||
return None
|
||||
|
||||
def update_on_priv_msg(self, data, connection: Connection):
|
||||
if data["channel"] == connection.details.get_channel():
|
||||
regex = r"\b(\w\d{2}\.?\d?\d?)\b"
|
||||
codes = re.findall(regex, data["message"])
|
||||
for code in codes:
|
||||
code = code.capitalize()
|
||||
text = self.icd10_dict.get(code, False)
|
||||
if text == False:
|
||||
if "." in code:
|
||||
code += "-"
|
||||
else:
|
||||
code += ".-"
|
||||
text = self.icd10_dict.get(code, False)
|
||||
if text:
|
||||
connection.send_back(f"{code} - {text}", data)
|
||||
if data["message"].startswith(".icd "):
|
||||
if data["channel"] == connection.details.get_channel():
|
||||
regex = r"\b(\w\d{2}\.?\d?\d?)\b"
|
||||
codes = re.findall(regex, data["message"])
|
||||
for code in codes[:5]:
|
||||
code = code.capitalize()
|
||||
text = self.icd10_dict.get(code, False)
|
||||
if text == False:
|
||||
if "." in code:
|
||||
code += "-"
|
||||
else:
|
||||
code += ".-"
|
||||
text = self.icd10_dict.get(code, False)
|
||||
if text:
|
||||
connection.send_back(f"{code} - {text}", data)
|
||||
|
||||
Reference in New Issue
Block a user