From 0b48922688e7dfd1cb6d1a226d8c454f1f543271 Mon Sep 17 00:00:00 2001 From: Kreezxil Date: Tue, 13 Oct 2026 19:49:05 -0500 Subject: [PATCH 1/3] 1.0.0 Discord Random Text Formatter --- .../1.0.0/README.md | 57 ++++++++++ .../1.0.0/_manifest.yml | 7 ++ .../1.0.0/package.yml | 9 ++ .../1.0.0/scripts/random_discord_formatter.py | 103 ++++++++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 packages/random-discord-text-formatter/1.0.0/README.md create mode 100644 packages/random-discord-text-formatter/1.0.0/_manifest.yml create mode 100644 packages/random-discord-text-formatter/1.0.0/package.yml create mode 100644 packages/random-discord-text-formatter/1.0.0/scripts/random_discord_formatter.py diff --git a/packages/random-discord-text-formatter/1.0.0/README.md b/packages/random-discord-text-formatter/1.0.0/README.md new file mode 100644 index 00000000..c405f292 --- /dev/null +++ b/packages/random-discord-text-formatter/1.0.0/README.md @@ -0,0 +1,57 @@ +# Random Discord Formatter + +Minimal Tkinter helper that takes text, randomly applies Discord markdown (bold, italic, underline, strikethrough, code, spoiler, and combos) plus random case flipping, then prints the result to stdout. + +Designed to be launched from [Espanso](https://espanso.org/) so the formatted text gets pasted automatically. + +## What it does + +- Splits the input on whitespace (keeps spaces intact). +- Randomly flips the case of each letter (~50% chance). +- Wraps each word in one random Discord style (~70% chance; otherwise leaves it plain). +- Prints the result to stdout and exits. + +Because formatting is applied per whole word and spaces stay between the markers, Discord parses it correctly (no stray asterisks). + +## Espanso setup + +Trigger: `:randytext` + +Example snippet (adjust the path to wherever you keep the script): + +```yaml +- trigger: ":randytext" + replace: "{{output}}" + force_mode: clipboard + vars: + - name: output + type: shell + params: + cmd: "python3 /path/to/random_discord_formatter.py" +``` + +`force_mode: clipboard` is recommended so multi-line results paste cleanly into Discord and other Electron apps. + +## Usage + +1. Type `:randytext` and hit your Espanso trigger key. +2. A small window appears. +3. Type your text. + - **Return** or **OK** → formats it, prints to stdout, closes. + - **Shift+Return** → inserts a newline. + - **Cancel** / **Escape** / window close → exits with no output. +4. Espanso pastes the result. + +## Requirements + +- Python 3 with Tkinter (usually included; on some Linux distros you may need the `python3-tk` package). + +## Files + +- `random_discord_formatter.py` — the script + +## Notes + +- Formatting styles used: plain, bold, italic, bold italic, underline, bold underline, italic underline, strikethrough, bold strikethrough, italic strikethrough, inline code, spoiler. +- Case flipping only affects letters. +- Empty input shows a message and stays open so you can try again. diff --git a/packages/random-discord-text-formatter/1.0.0/_manifest.yml b/packages/random-discord-text-formatter/1.0.0/_manifest.yml new file mode 100644 index 00000000..44eedfe3 --- /dev/null +++ b/packages/random-discord-text-formatter/1.0.0/_manifest.yml @@ -0,0 +1,7 @@ +name: "randytext" +title: "Randy Text" +description: "Random Discord markdown formatting and case flipping via a minimal Python/Tkinter prompt. Perfect for chaotic but valid Discord messages. Use :randytext to trigger it. Created on Linux." +homepage: "https://github.com/kreezxil/espanso-packages" +version: 1.0.0 +author: Kreezxil +tags: [ "discord", "markdown", "formatting", "python", "fun", "text" ] diff --git a/packages/random-discord-text-formatter/1.0.0/package.yml b/packages/random-discord-text-formatter/1.0.0/package.yml new file mode 100644 index 00000000..f2108b86 --- /dev/null +++ b/packages/random-discord-text-formatter/1.0.0/package.yml @@ -0,0 +1,9 @@ +matches: + - trigger: ":randytext" + replace: "{{output}}" + vars: + - name: output + type: shell + params: + cmd: "nohup python3 $CONFIG/scripts/random_discord_formatter.py 2>&1 &" + diff --git a/packages/random-discord-text-formatter/1.0.0/scripts/random_discord_formatter.py b/packages/random-discord-text-formatter/1.0.0/scripts/random_discord_formatter.py new file mode 100644 index 00000000..ee1cfce4 --- /dev/null +++ b/packages/random-discord-text-formatter/1.0.0/scripts/random_discord_formatter.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python3 +""" +Random Discord Formatter for Espanso +Minimal GUI: type text, hit Return or OK → prints formatted result to stdout and exits. +Cancel exits with no output. +""" + +import tkinter as tk +from tkinter import messagebox +import random +import re +import sys + +FORMATTERS = [ + lambda s: s, + lambda s: f"**{s}**", + lambda s: f"*{s}*", + lambda s: f"***{s}***", + lambda s: f"__{s}__", + lambda s: f"**__{s}__**", + lambda s: f"*__{s}__*", + lambda s: f"~~{s}~~", + lambda s: f"**~~{s}~~**", + lambda s: f"*~~{s}~~*", + lambda s: f"`{s}`", + lambda s: f"||{s}||", +] + +def random_case_word(word: str) -> str: + return "".join( + c.swapcase() if c.isalpha() and random.random() < 0.5 else c + for c in word + ) + +def apply_random_discord(text: str) -> str: + if not text.strip(): + return text + parts = re.split(r'(\s+)', text) + result = [] + for part in parts: + if not part or part.isspace(): + result.append(part) + continue + word = random_case_word(part) + if random.random() < 0.7: + word = random.choice(FORMATTERS)(word) + result.append(word) + return "".join(result) + +class App: + def __init__(self, root): + self.root = root + root.title("Discord Format") + root.geometry("420x140") + root.resizable(False, False) + + # Center-ish and stay on top + root.attributes("-topmost", True) + root.after(100, lambda: root.attributes("-topmost", False)) + + tk.Label(root, text="Text:").pack(anchor="w", padx=10, pady=(10, 0)) + + self.entry = tk.Text(root, height=3, wrap=tk.WORD) + self.entry.pack(fill=tk.BOTH, expand=True, padx=10, pady=5) + self.entry.focus_set() + + btn_frame = tk.Frame(root) + btn_frame.pack(fill=tk.X, padx=10, pady=(0, 10)) + + tk.Button(btn_frame, text="OK", width=10, command=self.ok).pack(side=tk.RIGHT, padx=5) + tk.Button(btn_frame, text="Cancel", width=10, command=self.cancel).pack(side=tk.RIGHT) + + # Return and Ctrl+Return both submit + self.entry.bind("", self.on_return) + self.entry.bind("", self.on_return) + root.bind("", lambda e: self.cancel()) + + root.protocol("WM_DELETE_WINDOW", self.cancel) + + def on_return(self, event): + # Allow Shift+Return for newline, plain Return submits + if event.state & 0x1: # Shift held + return + self.ok() + return "break" + + def ok(self): + raw = self.entry.get("1.0", tk.END).rstrip("\n") + if not raw.strip(): + messagebox.showinfo("Empty", "Enter some text first.", parent=self.root) + return + result = apply_random_discord(raw) + print(result, flush=True) + self.root.destroy() + + def cancel(self): + self.root.destroy() + +if __name__ == "__main__": + root = tk.Tk() + App(root) + root.mainloop() + sys.exit(0) From 0adb80ddb04d2fb68f0897c6eed6967d5e019ace Mon Sep 17 00:00:00 2001 From: Kreezxil Date: Wed, 14 Oct 2026 12:46:30 -0500 Subject: [PATCH 2/3] 1.0.0 again, with more smeechiness --- .../1.0.0/README.md | 31 +++---------------- .../1.0.0/_manifest.yml | 8 ++--- .../1.0.0/package.yml | 6 ++-- ...er.py => random_discord_text_formatter.py} | 0 4 files changed, 13 insertions(+), 32 deletions(-) rename packages/random-discord-text-formatter/1.0.0/{scripts/random_discord_formatter.py => random_discord_text_formatter.py} (100%) diff --git a/packages/random-discord-text-formatter/1.0.0/README.md b/packages/random-discord-text-formatter/1.0.0/README.md index c405f292..249c2c95 100644 --- a/packages/random-discord-text-formatter/1.0.0/README.md +++ b/packages/random-discord-text-formatter/1.0.0/README.md @@ -1,6 +1,6 @@ # Random Discord Formatter -Minimal Tkinter helper that takes text, randomly applies Discord markdown (bold, italic, underline, strikethrough, code, spoiler, and combos) plus random case flipping, then prints the result to stdout. +Minimal Python helper that takes text, randomly applies Discord markdown (bold, italic, underline, strikethrough, code, spoiler, and combos) plus random case flipping, then prints the result to stdout. Designed to be launched from [Espanso](https://espanso.org/) so the formatted text gets pasted automatically. @@ -13,45 +13,24 @@ Designed to be launched from [Espanso](https://espanso.org/) so the formatted te Because formatting is applied per whole word and spaces stay between the markers, Discord parses it correctly (no stray asterisks). -## Espanso setup - -Trigger: `:randytext` - -Example snippet (adjust the path to wherever you keep the script): - -```yaml -- trigger: ":randytext" - replace: "{{output}}" - force_mode: clipboard - vars: - - name: output - type: shell - params: - cmd: "python3 /path/to/random_discord_formatter.py" -``` - -`force_mode: clipboard` is recommended so multi-line results paste cleanly into Discord and other Electron apps. - ## Usage -1. Type `:randytext` and hit your Espanso trigger key. +1. Type `:randytext`. 2. A small window appears. 3. Type your text. - - **Return** or **OK** → formats it, prints to stdout, closes. - - **Shift+Return** → inserts a newline. - - **Cancel** / **Escape** / window close → exits with no output. 4. Espanso pastes the result. ## Requirements -- Python 3 with Tkinter (usually included; on some Linux distros you may need the `python3-tk` package). +- Python ## Files -- `random_discord_formatter.py` — the script +- `random_discord_text_formatter.py` — the script ## Notes - Formatting styles used: plain, bold, italic, bold italic, underline, bold underline, italic underline, strikethrough, bold strikethrough, italic strikethrough, inline code, spoiler. - Case flipping only affects letters. - Empty input shows a message and stays open so you can try again. + diff --git a/packages/random-discord-text-formatter/1.0.0/_manifest.yml b/packages/random-discord-text-formatter/1.0.0/_manifest.yml index 44eedfe3..041aa131 100644 --- a/packages/random-discord-text-formatter/1.0.0/_manifest.yml +++ b/packages/random-discord-text-formatter/1.0.0/_manifest.yml @@ -1,7 +1,7 @@ -name: "randytext" -title: "Randy Text" -description: "Random Discord markdown formatting and case flipping via a minimal Python/Tkinter prompt. Perfect for chaotic but valid Discord messages. Use :randytext to trigger it. Created on Linux." -homepage: "https://github.com/kreezxil/espanso-packages" +name: "random-discord-text-formatter" +title: "Random Discord Text Formatter" +description: "Random Discord markdown formatting and case flipping via a minimal Python/Espanso prompt. Perfect for chaotic but valid Discord messages. Use :randytext to trigger it." +homepage: "https://github.com/kreezxil/hub/" version: 1.0.0 author: Kreezxil tags: [ "discord", "markdown", "formatting", "python", "fun", "text" ] diff --git a/packages/random-discord-text-formatter/1.0.0/package.yml b/packages/random-discord-text-formatter/1.0.0/package.yml index f2108b86..acda7194 100644 --- a/packages/random-discord-text-formatter/1.0.0/package.yml +++ b/packages/random-discord-text-formatter/1.0.0/package.yml @@ -3,7 +3,9 @@ matches: replace: "{{output}}" vars: - name: output - type: shell + type: script params: - cmd: "nohup python3 $CONFIG/scripts/random_discord_formatter.py 2>&1 &" + args: + - python + - "%CONFIG%/match/packages/random-discord-text-formatter/random_discord_formatter.py" diff --git a/packages/random-discord-text-formatter/1.0.0/scripts/random_discord_formatter.py b/packages/random-discord-text-formatter/1.0.0/random_discord_text_formatter.py similarity index 100% rename from packages/random-discord-text-formatter/1.0.0/scripts/random_discord_formatter.py rename to packages/random-discord-text-formatter/1.0.0/random_discord_text_formatter.py From ac6a4d0ee09d2935cb9ccd4df11f7d117df1fda8 Mon Sep 17 00:00:00 2001 From: Kreezxil Date: Wed, 14 Oct 2026 13:07:37 -0500 Subject: [PATCH 3/3] 1.0.0 this should be it. --- .../1.0.0/README.md | 25 +++-- .../1.0.0/package.yml | 14 ++- .../1.0.0/random_discord_text_formatter.py | 106 ++++++------------ 3 files changed, 56 insertions(+), 89 deletions(-) diff --git a/packages/random-discord-text-formatter/1.0.0/README.md b/packages/random-discord-text-formatter/1.0.0/README.md index 249c2c95..ad489de4 100644 --- a/packages/random-discord-text-formatter/1.0.0/README.md +++ b/packages/random-discord-text-formatter/1.0.0/README.md @@ -1,36 +1,37 @@ # Random Discord Formatter -Minimal Python helper that takes text, randomly applies Discord markdown (bold, italic, underline, strikethrough, code, spoiler, and combos) plus random case flipping, then prints the result to stdout. - -Designed to be launched from [Espanso](https://espanso.org/) so the formatted text gets pasted automatically. +Minimal Python helper that takes text from an Espanso form, randomly applies Discord markdown (bold, italic, underline, strikethrough, code, spoiler, and combos) plus random case flipping, then prints the result to stdout so Espanso can paste it. ## What it does +- Prompts via Espanso form (multiline text field). - Splits the input on whitespace (keeps spaces intact). - Randomly flips the case of each letter (~50% chance). -- Wraps each word in one random Discord style (~70% chance; otherwise leaves it plain). -- Prints the result to stdout and exits. +- Wraps each word in one random Discord style. +- Prints the result to stdout. Because formatting is applied per whole word and spaces stay between the markers, Discord parses it correctly (no stray asterisks). ## Usage 1. Type `:randytext`. -2. A small window appears. -3. Type your text. -4. Espanso pastes the result. +2. Espanso shows a form with a multiline text field. +3. Enter your text and submit (Submit button or Ctrl+Enter). +4. The formatted result is pasted. ## Requirements -- Python +- Python 3 ## Files - `random_discord_text_formatter.py` — the script +- `package.yml` — Espanso match + form definition +- `_manifest.yml` — package metadata ## Notes -- Formatting styles used: plain, bold, italic, bold italic, underline, bold underline, italic underline, strikethrough, bold strikethrough, italic strikethrough, inline code, spoiler. +- Formatting styles: bold, italic, bold italic, underline, bold underline, italic underline, strikethrough, bold strikethrough, italic strikethrough, inline code, spoiler. - Case flipping only affects letters. -- Empty input shows a message and stays open so you can try again. - +- Empty form submission produces no output. +- The script path in `package.yml` uses `%CONFIG%` so it resolves correctly after package installation. diff --git a/packages/random-discord-text-formatter/1.0.0/package.yml b/packages/random-discord-text-formatter/1.0.0/package.yml index acda7194..d3bd30cd 100644 --- a/packages/random-discord-text-formatter/1.0.0/package.yml +++ b/packages/random-discord-text-formatter/1.0.0/package.yml @@ -2,10 +2,18 @@ matches: - trigger: ":randytext" replace: "{{output}}" vars: + - name: form1 + type: form + params: + layout: | + Text to format: + [[text]] + fields: + text: + multiline: true - name: output type: script params: args: - - python - - "%CONFIG%/match/packages/random-discord-text-formatter/random_discord_formatter.py" - + - python3 + - "%CONFIG%/match/packages/random-discord-text-formatter/random_discord_text_formatter.py" diff --git a/packages/random-discord-text-formatter/1.0.0/random_discord_text_formatter.py b/packages/random-discord-text-formatter/1.0.0/random_discord_text_formatter.py index ee1cfce4..6a4942f1 100644 --- a/packages/random-discord-text-formatter/1.0.0/random_discord_text_formatter.py +++ b/packages/random-discord-text-formatter/1.0.0/random_discord_text_formatter.py @@ -1,103 +1,61 @@ #!/usr/bin/env python3 """ Random Discord Formatter for Espanso -Minimal GUI: type text, hit Return or OK → prints formatted result to stdout and exits. -Cancel exits with no output. +Reads text from the Espanso form (via ESPANSO_FORM1_TEXT), +applies random Discord markdown + case flipping, and prints the result. """ -import tkinter as tk -from tkinter import messagebox +import os import random import re import sys FORMATTERS = [ - lambda s: s, - lambda s: f"**{s}**", - lambda s: f"*{s}*", - lambda s: f"***{s}***", - lambda s: f"__{s}__", - lambda s: f"**__{s}__**", - lambda s: f"*__{s}__*", - lambda s: f"~~{s}~~", - lambda s: f"**~~{s}~~**", - lambda s: f"*~~{s}~~*", - lambda s: f"`{s}`", - lambda s: f"||{s}||", + lambda s: f"**{s}**", # bold + lambda s: f"*{s}*", # italic + lambda s: f"***{s}***", # bold italic + lambda s: f"__{s}__", # underline + lambda s: f"**__{s}__**", # bold underline + lambda s: f"*__{s}__*", # italic underline + lambda s: f"~~{s}~~", # strikethrough + lambda s: f"**~~{s}~~**", # bold strikethrough + lambda s: f"*~~{s}~~*", # italic strikethrough + lambda s: f"`{s}`", # inline code + lambda s: f"||{s}||", # spoiler ] def random_case_word(word: str) -> str: + """Randomly flip case of each letter (~50% chance).""" return "".join( c.swapcase() if c.isalpha() and random.random() < 0.5 else c for c in word ) def apply_random_discord(text: str) -> str: - if not text.strip(): - return text - parts = re.split(r'(\s+)', text) + """ + Split on whitespace (preserve spaces), randomly case-flip letters, + then wrap each word in one Discord style. + """ + if not text or not text.strip(): + return "" + parts = re.split(r"(\s+)", text) result = [] for part in parts: if not part or part.isspace(): result.append(part) continue word = random_case_word(part) - if random.random() < 0.7: - word = random.choice(FORMATTERS)(word) - result.append(word) + formatter = random.choice(FORMATTERS) + result.append(formatter(word)) return "".join(result) -class App: - def __init__(self, root): - self.root = root - root.title("Discord Format") - root.geometry("420x140") - root.resizable(False, False) - - # Center-ish and stay on top - root.attributes("-topmost", True) - root.after(100, lambda: root.attributes("-topmost", False)) - - tk.Label(root, text="Text:").pack(anchor="w", padx=10, pady=(10, 0)) - - self.entry = tk.Text(root, height=3, wrap=tk.WORD) - self.entry.pack(fill=tk.BOTH, expand=True, padx=10, pady=5) - self.entry.focus_set() - - btn_frame = tk.Frame(root) - btn_frame.pack(fill=tk.X, padx=10, pady=(0, 10)) - - tk.Button(btn_frame, text="OK", width=10, command=self.ok).pack(side=tk.RIGHT, padx=5) - tk.Button(btn_frame, text="Cancel", width=10, command=self.cancel).pack(side=tk.RIGHT) - - # Return and Ctrl+Return both submit - self.entry.bind("", self.on_return) - self.entry.bind("", self.on_return) - root.bind("", lambda e: self.cancel()) - - root.protocol("WM_DELETE_WINDOW", self.cancel) - - def on_return(self, event): - # Allow Shift+Return for newline, plain Return submits - if event.state & 0x1: # Shift held - return - self.ok() - return "break" - - def ok(self): - raw = self.entry.get("1.0", tk.END).rstrip("\n") - if not raw.strip(): - messagebox.showinfo("Empty", "Enter some text first.", parent=self.root) - return - result = apply_random_discord(raw) - print(result, flush=True) - self.root.destroy() - - def cancel(self): - self.root.destroy() +def main() -> None: + # Form field "text" is exposed as ESPANSO_FORM1_TEXT + raw = os.environ.get("ESPANSO_FORM1_TEXT", "").strip() + if not raw: + # Empty form → nothing to expand + sys.exit(0) + print(apply_random_discord(raw), flush=True) if __name__ == "__main__": - root = tk.Tk() - App(root) - root.mainloop() - sys.exit(0) + main()