Skip to content

Instantly share code, notes, and snippets.

@Nerahikada
Created August 21, 2024 19:27
Show Gist options
  • Save Nerahikada/b01454f1cebad51cb6160253404325ff to your computer and use it in GitHub Desktop.
Save Nerahikada/b01454f1cebad51cb6160253404325ff to your computer and use it in GitHub Desktop.
くそ雑 Death by AI パーサー
import time
import pyperclip
def parse_result(contents):
prompt = income = life = None
read_next_line_1 = read_next_line_2 = False
for line in contents.split('\n'):
line = line.strip()
if line.startswith('プロンプト: '):
prompt = line[7:]
elif line.startswith('bolt'):
read_next_line_1 = True
elif read_next_line_1:
income = line
read_next_line_1 = False
elif line.startswith('life'):
read_next_line_2 = True
elif read_next_line_2:
life = line
read_next_line_2 = False
return prompt, income, life
def main():
cache = None
while True:
contents = pyperclip.paste()
if contents == cache:
time.sleep(1)
continue
cache = contents
prompt, income, life = parse_result(contents)
if prompt is None or income is None:
continue
md = f'# プロンプト\n```{prompt}```\n# 出力\n```{income}```'
if life is not None:
md += f'\n:heart: {life} 生き残った'
print(md)
pyperclip.copy(md)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment