https://github.com/jesewe/telegram-bot
A simple Telegram bot that provides helpful commands.
https://github.com/jesewe/telegram-bot
bot js node-telegram-bot-api telegram telegram-bot
Last synced: about 1 month ago
JSON representation
A simple Telegram bot that provides helpful commands.
- Host: GitHub
- URL: https://github.com/jesewe/telegram-bot
- Owner: Jesewe
- License: mit
- Created: 2024-10-19T04:54:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-25T05:44:51.000Z (about 1 year ago)
- Last Synced: 2025-03-30T10:26:40.430Z (12 months ago)
- Topics: bot, js, node-telegram-bot-api, telegram, telegram-bot
- Language: JavaScript
- Homepage: https://github.com/Jesewe/telegram-bot
- Size: 196 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Telegram Bot
A simple Telegram bot that provides helpful commands.
Features •
Installation •
Dependencies •
Logging
---
# Overview
**Telegram Bot** is a basic, informative Telegram bot that interacts with users via simple commands. It's built using the [node-telegram-bot-api](https://github.com/yagop/node-telegram-bot-api) library.
## Features
- **`/start`** - Sends a welcome message with an inline keyboard for quick access to help and bot info.
- **`/help`** - Lists all available commands for the user.
- **`/info`** - Provides detailed information about the bot.
- **`/joke`** - Fetches a random joke from an external joke API and sends it to the user.
- **`/weather `** - Retrieves current weather information for the specified city.
- **`/cat`** - Sends a random cute cat image.
- **`/dog`** - Sends a random cute dog image.
- **`/time`** - Shows the current server time.
- **Echo** - Any non-command text is echoed back to the user.
## Installation
1. **Clone this repository:**
```bash
git clone https://github.com/Jesewe/telegram-bot.git
cd telegram-bot
```
2. **Install the required dependencies:**
```bash
npm install
```
3. **Create a `config.json` file in the root directory with the following structure:**
```json
{
"token": "YOUR_REAL_BOT_TOKEN_HERE",
"botName": "Telegram Bot"
}
```
4. **Run the bot:**
```bash
node bot.js
```
## Dependencies
- **[node-telegram-bot-api](https://github.com/yagop/node-telegram-bot-api)**: Telegram Bot API wrapper for Node.js.
- **[axios](https://axios-http.com/)**: HTTP client for making requests to external APIs (joke, weather, cat, and dog image APIs).
## Logging
When the bot starts, it logs the following to the console:
```bash
Telegram Bot is running...
```
Any polling errors or issues (e.g., while fetching a joke or weather data) are logged in the console with error details. For example:
```bash
Error fetching joke: Error message here
```
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.