diff --git a/CHANGELOG.md b/CHANGELOG.md index 28f9261eebccbed9d66d6c6aa9a4ec116c2b232b..9c655b8b7d864d288a708e1d55420afec765d205 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v2.3.2 +- **Added:** `!cocobot` command which displays information about the bot itself. - **Added:** A tribute to our lost soul, `@Nal`, whenever his username is mentioned. - **Improved:** Clarified and expanded code comments throughout `bot.py` for better maintainability. - **Fixed:** Minor cooldown logic for the `tate` command (cooldown message now says 5 minutes, logic is 3 minutes). @@ -57,7 +58,7 @@ ## v2.0.0 -* cocobot v2 is a completely rewritten version of the initial cocobot Discord bot for the Thailand Discord server. At this point, all features from the first, less maintainable version have been reprogrammed in a way that allows other contributors to add functions easily. Already existing functions have been drastically improved; the output quality is at the highest rate so far. +*cocobot v2 is a completely rewritten version of the initial cocobot Discord bot for the Thailand Discord server. At this point, all features from the first, less maintainable version have been reprogrammed in a way that allows other contributors to add functions easily. Already existing functions have been drastically improved; the output quality is at the highest rate so far.* ## v1.2.4 diff --git a/README.md b/README.md index e64d50727320a3cf927268f856e9ce38c27a2da8..b730267587f46a5cdc91f7f5880c20ed0533d4b2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🥥 cocobot -![GitLab Release](https://img.shields.io/gitlab/v/release/thaikolja%2Fdiscord-cocobot?style=flat&label=version&color=%23d87630&link=https%3A%2F%2Fgitlab.com%2Fthaikolja%2Fdiscord-cocobot) [![pipeline status](https://gitlab.com/thailand-discord/bots/cocobot/badges/main/pipeline.svg)](https://gitlab.com/thailand-discord/bots/cocobot/-/commits/main) [![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-blue.svg)](LICENSE) [![Python Version](https://img.shields.io/badge/Python-3.8%2B-blue.svg)](https://www.python.org/downloads/) +![GitLab Release](https://img.shields.io/gitlab/v/release/thaikolja%2Fdiscord-cocobot?style=flat&label=version&color=%23d87630&link=https%3A%2F%2Fgitlab.com%2Fthaikolja%2Fdiscord-cocobot) [![pipeline status](https://gitlab.com/thailand-discord/bots/cocobot/badges/main/pipeline.svg)](https://gitlab.com/thailand-discord/bots/cocobot/-/commits/main) ![GitLab License](https://img.shields.io/gitlab/license/thailand-discord%2Fbots%2Fcocobot?style=flat) [![Python Version](https://img.shields.io/badge/Python-3.8%2B-blue.svg)](https://www.python.org/downloads/) **@cocobot** is your friendly, feature-rich **Discord bot** designed for the [**Discord Thailand** server](https://discord.gg/6JXCqVdmTZ), bringing a tropical twist to your server with useful utilities and fun interactions. Built with **Python** and the `discord.py` library, cocobot offers **a variety of commands** for practical tasks like weather checking, translation, and currency conversion, all wrapped in a coconut-themed package. @@ -82,7 +82,7 @@ **Returns:** "🇹🇭 ห้องน้ำอยู่ที่ไหน"[^4] -### Transliterate the translated text into the Latin alphabet +### Transliterate Thai text into the Latin alphabet ```bash /transliterate text: "ห้องน้ำอยู่ที่ไหน" @@ -178,7 +178,7 @@ We welcome contributions via Git! Please follow these standard steps: ## 📜 License -**cocobot** is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. See the [LICENSE](LICENSE) file for details. +**cocobot** is licensed under the MIT License. See the [LICENSE](https://opensource.org/licenses/MIT) file for details. --- @@ -195,4 +195,4 @@ We welcome contributions via Git! Please follow these standard steps: [^1]: Using `.` works only if the current directory is completely empty. If not, leave don't use it and use `mv ./discord-bot/{*,.*} ../` [^2]: Keep your `.env` file secret and remember to add it to the `.gitignore` file. [^3]: Uses Perplexity's AI LLM "Sonar Pro" and can produce inaccuracies. -[^4]: Since `v2.2.0`, this is being handled by *Gemini 2.0 Flash Lite.* An API key is required, but usage of up to a million tokens is free. \ No newline at end of file +[^4]: Since `v2.2.0`, this has been handled by *Gemini 2.0 Flash Lite.* An API key is required, but usage of up to a million tokens is free. \ No newline at end of file diff --git a/bot.py b/bot.py index 8fc4c57b3aecaa74c8629c807c698ea00c056c90..9fde6ec2375a73ff766c4ffccf48f427b0bfba4f 100755 --- a/bot.py +++ b/bot.py @@ -136,6 +136,45 @@ class Cocobot(commands.Bot): # Exit the handler if the message is from the bot return + # Set the flag for sending the Cocobot info embed to False, because we don't want to spam... yet + send_cocobot_info_embed = False + + # Strip the message content of any leading/trailing whitespace, because users love their accidental spaces + normalized_message_content_stripped = message.content.strip() + + # Condition 1: Did someone type '!cocobot'? Maybe they're looking for the coconut overlord + if normalized_message_content_stripped.lower() == '!cocobot': + send_cocobot_info_embed = True # Time to show off Cocobot's resume + + # If the flag is set, it's showtime for Cocobot's info embed + if send_cocobot_info_embed: + embed = discord.Embed( + # Set the timestamp to the current time, because we want to be timely + timestamp=datetime.now(), + # Because every bot needs a dramatic entrance + title=f"🥥 Cocobot at your service!", + # For the developers + url="https://gitlab.com/thailand-discord/bots/cocobot", + # Coconut puns included at no extra charge + description=f"Hi, I'm **@cocobot** `v{COCOBOT_VERSION}`, the *actual* useful brother of our dearest August Engelhardt. Type `/coco` to see what I can do for you. I " + "promise " + "on the holy coconut, I'm here to help.", + # Because green is the color of coconuts (sometimes) + color=discord.Color.green(), + ) + + # Add a footer to the embed, because every good bot needs a signature + if self.user.display_avatar: + # Show off that beautiful bot avatar + embed.set_thumbnail(url=self.user.display_avatar.url) + + # Set the footer text with a coconut-themed message + embed.set_footer(text=f"© Coconut wisdom since 1875") + # Send the embed, because bots need attention too + await message.channel.send(embed=embed) + # No more processing, the coconut has spoken + return + # Define the regular expression pattern to detect the word 'tate' case-insensitively, ensuring it's a whole word tate_pattern = r'(?