{"id":32597765,"url":"https://github.com/flagro/telegramhaikubot","last_synced_at":"2026-07-03T02:03:38.865Z","repository":{"id":321007161,"uuid":"1084073942","full_name":"Flagro/TelegramHaikuBot","owner":"Flagro","description":"Telegram bot that detects haikus in a group chat","archived":false,"fork":false,"pushed_at":"2025-11-04T16:26:03.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-04T18:19:40.283Z","etag":null,"topics":["haiku","python","telegram","telegrambot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Flagro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-27T07:23:30.000Z","updated_at":"2025-11-04T16:26:07.000Z","dependencies_parsed_at":"2025-10-27T09:35:48.394Z","dependency_job_id":null,"html_url":"https://github.com/Flagro/TelegramHaikuBot","commit_stats":null,"previous_names":["flagro/telegramhaikubot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Flagro/TelegramHaikuBot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagro%2FTelegramHaikuBot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagro%2FTelegramHaikuBot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagro%2FTelegramHaikuBot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagro%2FTelegramHaikuBot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flagro","download_url":"https://codeload.github.com/Flagro/TelegramHaikuBot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagro%2FTelegramHaikuBot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35069183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haiku","python","telegram","telegrambot"],"created_at":"2025-10-30T05:01:48.886Z","updated_at":"2026-07-03T02:03:38.857Z","avatar_url":"https://github.com/Flagro.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TelegramHaikuBot\n\nA Telegram bot that detects haikus in messages using intelligent pattern recognition. The bot can find haikus anywhere within longer text messages and supports multiple detection modes.\n\n## Features\n\n- **Smart Detection**: Finds haikus embedded in any continuous text, not just perfectly formatted messages\n- **Flexible Modes**: Choose between detecting the first haiku or all haikus in a message\n- **Per-Chat Settings**: Each chat/group has independent state and configuration\n- **Dynamic Configuration**: Change detection mode on-the-fly with commands\n- **Beautiful Formatting**: Detected haikus are formatted in italic for emphasis\n- **Access Control**: Optional whitelist for allowed users and administrators\n\n## Setup\n\n1. Install dependencies:\n```bash\npoetry install\n```\n\n2. Create a `.env` file with your bot token:\n```\nTELEGRAM_BOT_TOKEN=your_token_here\nALLOWED_HANDLES=  # Optional: comma-separated list of allowed usernames\nADMIN_HANDLES=    # Optional: comma-separated list of admin usernames\n```\n\n3. Run the bot:\n```bash\npoetry run python main.py\n```\n\n## Commands\n\n- `/start` - Activate the bot in the current chat\n- `/stop` - Deactivate the bot in the current chat\n- `/mode` - Open keyboard to select detection mode (STRICT or RANDOM)\n\n## Detection Modes\n\n### 🎯 STRICT Mode (Default)\nOnly detects haikus if your **entire message** is exactly a haiku with no extra text. Perfect for when you want to share a pure haiku.\n\n**Example:**\n```\nAn old silent pond\nA frog jumps into the pond\nSplash! Silence again\n```\n✓ Bot will respond - this is exactly a haiku!\n\n```\nHey! An old silent pond A frog jumps into the pond Splash! Silence again\n```\n✗ Bot won't respond - extra text before the haiku\n\n### 🎲 RANDOM Mode\nSearches your entire message for haikus and returns one randomly selected haiku if multiple are found. Great for conversations where haikus might appear naturally!\n\n**Example:**\n```\nHere are my haikus: An old silent pond A frog jumps into the pond splash silence again. And another: Over the wintry forest winds howl in a rage with no leaves to blow.\n```\n✓ Bot will find both haikus and return one randomly!\n\n## Usage Examples\n\n### 1. Activate and Set Mode\n\n```\nUser: /start\nBot: Hello! I'm a Haiku Bot 🌸 [...]\n\nUser: /mode\nBot: 🎛️ Current mode: STRICT\n     [Shows keyboard with STRICT and RANDOM buttons]\n\nUser: [Clicks RANDOM button]\nBot: 🔧 Detection mode set to: RANDOM\n```\n\n### 2. STRICT Mode Example\n\n```\nUser: An old silent pond\n      A frog jumps into the pond\n      Splash! Silence again\n\nBot: 🌸 Haiku detected:\n     _An old silent pond_\n     _A frog jumps into the pond_\n     _Splash! Silence again_\n```\n\n### 3. RANDOM Mode Example\n\n```\nUser: I wrote some haikus today. An old silent pond A frog jumps into \n      the pond splash silence again. Here's another one Over the wintry \n      forest winds howl in a rage with no leaves to blow. What do you think?\n\nBot: 🌸 Haiku detected:\n     _Over the wintry_\n     _forest winds howl in a rage_\n     _with no leaves to blow_\n```\n(Randomly selected from the multiple haikus found)\n\n## How It Works\n\n### Detection Algorithm\n\nThe bot uses a sliding window algorithm to scan through messages:\n\n1. **STRICT Mode**: Checks if the entire message (all words) forms exactly one 5-7-5 haiku\n2. **RANDOM Mode**: Scans through the message to find all possible 5-7-5 patterns, then randomly selects one\n\n### Chat State Management\n\nEach chat/group maintains independent state:\n- **Active/Inactive**: Whether the bot responds to messages (use `/start` and `/stop`)\n- **Detection Mode**: STRICT (exact match) or RANDOM (search and pick random)\n\nStates are stored in-memory during the bot's runtime.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflagro%2Ftelegramhaikubot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflagro%2Ftelegramhaikubot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflagro%2Ftelegramhaikubot/lists"}