tg-word-reminder

module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2024 License: MIT

README

Telegram Word Pair Reminder Bot

This is a Telegram bot built using Go that allows users to upload word pairs and receive reminders with those pairs.

Features

  • Upload word pairs in the format word1,word2.
  • Clear uploaded word pairs.
  • Set the number of pairs to send in reminders.
  • Set the frequency of reminders per day.
  • Periodic reminders sent to users with random word pairs.

Prerequisites

  • Go 1.23 or newer
  • PostgreSQL database
  • A Telegram bot token (create one using BotFather)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-directory>
    
  2. Install dependencies:

    go mod tidy
    
  3. Create a configuration file: Create a config.json file in the root directory of the project with the following structure:

    {
        "database": {
            "host": "your-database-host",
            "user": "your-database-user",
            "password": "your-database-password",
            "dbname": "your-database-name",
            "port": "your-database-port",
            "sslmode": "require"
        },
        "telegram": {
            "token": "your-telegram-bot-token"
        }
    }
    
  4. Run the bot:

    go build ./cmd/tg-word-reminder
    ./tg-word-reminder
    

Usage

You can send a CSV file with word pairs to the bot to upload them. Please refer to the example file example.csv for the correct format.

  • Commands:
    • /getpair: Get a random word pair.
    • /clear: Clear all uploaded word pairs.
    • /setnum <number>: Set the number of pairs to send in reminders.
    • /setfreq <number>: Set the frequency of reminders per day.

Database Setup

The bot uses a PostgreSQL database. Ensure that the database is set up and accessible based on the configuration provided in config.json. The bot will automatically create the necessary tables for storing word pairs and user settings.

Logging

The bot uses the standard library's slog package for logging. Logs will be printed to the console.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

Directories

Path Synopsis
cmd
tg-word-reminder command
cmd/yourbot/main.go
cmd/yourbot/main.go
pkg
bot
pkg/bot/handlers.go
pkg/bot/handlers.go
db
pkg/db/models.go
pkg/db/models.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL