class SnippetSummonerStr:
# funnels strings into lookup keys
def __init__(self):
self.incantations: set[str] = set()
self.exclusions: set[str] = set()
def getSummonerStr(self, str1:str)->str:
# check for summon incantation in str start
for item in self.incantations:
if str1.startswith(item):
str1 = str1.replace(item, "")
# clean out none relevant lookup phrases
for item1 in self.exclusions:
str1 = str1.replace(item1, "")
# ret alphabetized cleaned result
return f"{item} {" ".join(sorted(str1.split()))}"
return ""
class SnippetSummonerStr:
# funnels strings into lookup keys
def __init__(self):
self.incantations: set[str] = set()
self.exclusions: set[str] = set()
def getSummonerStr(self, str1:str)->str:
# check for summon incantation in str start
for item in self.incantations:
if str1.startswith(item):
str1 = str1.replace(item, "")
# clean out none relevant lookup phrases
for item1 in self.exclusions:
str1 = str1.replace(item1, "")
# ret alphabetized cleaned result
return f"{item} {" ".join(sorted(str1.split()))}"
return ""
class SnippetStore(PopulatorFunc):
def __init__(self):
super().__init__()
self.regex = "snippet"
def populate(self, railbot: RailChatBot, str1: str):
keyword = "code"
pattern = rf"{keyword}\s+(.*?)\s+ok\s+(.*)"
v1, v2 = re.fullmatch(pattern, str1).groups()
print(f"{keyword} {v1} {v2}")
railbot.learn_key_value(f"{keyword} {v1}", v2)
class SnippetStore(PopulatorFunc):
def __init__(self):
super().__init__()
self.regex = "snippet"
self.exclusions: set[str] = set()
def populate(self, railbot: RailChatBot, str1: str):
keyword = "code"
pattern = rf"{keyword}\s+(.*?)\s+ok\s+(.*)"
v1, v2 = re.fullmatch(pattern, str1).groups()
if len(v1)>0 and len(v2)>0:
for item1 in self.exclusions:
v1 = v1.replace(item1, "")
railbot.learn_key_value(f"{keyword} {v1}", v2)