jizzbox snippet storer

fukurou

the supreme coder
ADMIN
Python:
import re

text = "code xx yy ok zz"

# extract "xx yy"
m1 = re.search(r"code\s+(.*?)\s+ok", text)
v1 = m1.group(1) if m1 else None

# extract "zz"
m2 = re.search(r"ok\s+(.*)$", text)
v2 = m2.group(1) if m2 else None

print(v1)  # xx yy
print(v2)  # zz
 

fukurou

the supreme coder
ADMIN
v2:
Python:
import re

text = "code xx yy ok zz"

# Strict full‑structure match
v1, v2 = re.fullmatch(r"code\s+(.*?)\s+ok\s+(.*)", text).groups()

print(v1)  # xx yy
print(v2)  # zz
 

fukurou

the supreme coder
ADMIN
Python:
import re

text = "code xx yy ok zz"
keyword = "code"

pattern = rf"{keyword}\s+(.*?)\s+ok\s+(.*)"
v1, v2 = re.fullmatch(pattern, text).groups()

print(v1)  # xx yy
print(v2)  # zz
 

fukurou

the supreme coder
ADMIN
Python:
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 ""
 

fukurou

the supreme coder
ADMIN
Python:
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 ""

Python:
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)
 

fukurou

the supreme coder
ADMIN
Python:
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)
 
Top