{"id":19871318,"url":"https://github.com/mehdislr/jokebots_bot","last_synced_at":"2025-03-01T00:47:32.763Z","repository":{"id":245582705,"uuid":"798019163","full_name":"MehdiSlr/JokeBots_Bot","owner":"MehdiSlr","description":"JokeBot is a simple Telegram bot that sends random jokes or jokes containing specific words provided by the user.","archived":false,"fork":false,"pushed_at":"2024-07-05T05:04:42.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-11T16:34:57.994Z","etag":null,"topics":["api","joke","joke-api","php","telegram-bot"],"latest_commit_sha":null,"homepage":"https://t.me/JokeBots_Bot","language":"PHP","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/MehdiSlr.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}},"created_at":"2024-05-08T23:46:24.000Z","updated_at":"2024-07-05T05:04:46.000Z","dependencies_parsed_at":"2025-01-11T16:30:27.250Z","dependency_job_id":"a9e2a284-2ad6-48ec-b5a5-e174d60cd8fb","html_url":"https://github.com/MehdiSlr/JokeBots_Bot","commit_stats":null,"previous_names":["mehdislr/jokebots_bot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MehdiSlr%2FJokeBots_Bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MehdiSlr%2FJokeBots_Bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MehdiSlr%2FJokeBots_Bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MehdiSlr%2FJokeBots_Bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MehdiSlr","download_url":"https://codeload.github.com/MehdiSlr/JokeBots_Bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241295177,"owners_count":19939771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","joke","joke-api","php","telegram-bot"],"created_at":"2024-11-12T16:11:55.458Z","updated_at":"2025-03-01T00:47:32.744Z","avatar_url":"https://github.com/MehdiSlr.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JokeBot\n\nJokeBot is a simple Telegram bot designed to send jokes to users based on various categories or specific words. The bot uses the [JokeAPI](https://v2.jokeapi.dev/) to fetch jokes and interacts with users through the Telegram API.\n\n## Features\n\n- Send random jokes from multiple categories.\n- Send jokes containing specific words provided by the user.\n- Language selection feature to support multilingual user interactions.\n- Provides bot information and usage instructions.\n- Logs interactions for debugging and improvement.\n\n## Requirements\n\n- PHP 7.4 or higher\n- cURL extension for PHP\n- A Telegram bot token\n- MySQL or compatible database\n\n## Installation\n\nFollow these steps to set up the bot:\n\n1. Clone the repository\n\nClone the repository to your local machine and navigate into the project directory:\n\n```sh\ngit clone https://github.com/MehdiSlr/JokeBots_Bot.git\ncd JokeBots_Bot\n```\n\n2. Install Dependencies\n\nThere are no specific PHP dependencies to install via Composer at the moment, but ensure you have the cURL extension enabled.\n\n3. Configure `config.php`\n\nCreate a `config.php` file in the project root directory with your Telegram bot token and database details:\n\n```php\n\u003c?php\n$token = 'YOUR_TELEGRAM_BOT_TOKEN';\n$conn = mysqli_connect('YOUR_DATABASE_HOST', 'YOUR_DATABASE_USERNAME', 'YOUR_DATABASE_PASSWORD', 'YOUR_DATABASE_NAME');\n?\u003e\n```\n\n4. Set the Bot Webhook\n\nSet the webhook URL for the bot by entering the following URL in your browser:\n\n```sh\nhttps://api.telegram.org/bot\u003cYOUR_TELEGRAM_BOT_TOKEN\u003e/setWebhook?url=\u003cYOUR_HOST_URL\u003e/index.php\n```\n5. Update the Database Schema\n\nEnsure that your database has the necessary tables for the bot. Here’s an example SQL schema to set up the `users` and `update_log` tables:\n\n```sql\nCREATE TABLE `users` (\n    `uid` BIGINT PRIMARY KEY,\n    `name` VARCHAR(255),\n    `user` VARCHAR(255),\n    `type` VARCHAR(255),\n    `cat` VARCHAR(255),\n    `lang` VARCHAR(5)\n);\n\nCREATE TABLE `update_log` (\n    `id` INT AUTO_INCREMENT PRIMARY KEY,\n    `json` TEXT\n);\n```\n\n6. Start the Bot\n\nStart a conversation with the bot on Telegram to initiate interaction.\n\n## Usage\n\n### Sending Messages\n\nThe `msg` function is used to send messages to the Telegram bot. It takes two parameters: the API method and the parameters for the method.\n\n```php\nmsg('sendMessage', [\n    'chat_id' =\u003e $chat_id,\n    'text' =\u003e $message,\n]);\n```\n\n### Fetching Jokes\n\nThe `Joke` function is used to fetch a joke from the JokeAPI based on a category and a search term.\n\n```php\n$joke = Joke('Programming', 'bug');\n```\n\n### Formatting Jokes\n\nThe `JokeMsg` function is used to format a joke message with its category.\n\n```php\n$formatted_joke = JokeMsg('Programming', 'Why do programmers prefer dark mode?');\n```\n\n### Predefined Text Messages\n\nThe `text` function is used to retrieve predefined text messages for the bot.\n\n```php\n$welcome_message = text('welcome');\n```\n\n### Keyboard Layout\n\nThe `keyboard` function is used to generate the appropriate keyboard layout for the bot.\n\n```php\n$keyboard = keyboard('home');\n```\n\n## Bot Commands and Callbacks\n\nThe bot responds to commands and callback queries:\n\n- `/start` - Displays the welcome message and main keyboard.\n- `Change Category | 🔄️` - Switches to custom joke mode.\n- `random` - Sends a random joke.\n- `custom` - Sends a joke containing the search term provided by the user.\n- `language` - Allows users to select a language preference.\n- `info` - Displays the bot and API information.\n- Callback queries for joke categories (`Any`, `Dark`, `Pun`, `Miscellaneous`, `Programming`, `Spooky`, `Christmas`).\n\n## Database Logging\n\nThe bot logs incoming updates to the `update_log` table for debugging purposes.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgements\n\n- [JokeAPI](https://github.com/official-joke-api) for providing the jokes.\n- [Telegram](https://core.telegram.org/bots/api) for the Telegram bot API.\n\n## Support\n\nIf you have any questions or feedback, please [open an issue](https://github.com/MehdiSlr/jokebot/issues/new) on GitHub.\n\n## Author\n\nCreated by [Mehdi Salari](https://github.com/MehdiSlr) - Telegram [@Meytttii](https://t.me/Meytttii).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehdislr%2Fjokebots_bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmehdislr%2Fjokebots_bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehdislr%2Fjokebots_bot/lists"}