Skip to content

A bot reply first Google search image when you type "[something].jpg"

License

Notifications You must be signed in to change notification settings

akira02/rust-tg.jpg

Repository files navigation

rust-tg.jpg

GitHub Actions Workflow Status

Sometimes words aren't enough to express your emotions, and searching for stickers or GIFs can be a hassle.
Try tg.jpg! It's like Google's "I'm Feeling Lucky" but for images, this bot will instantly reply with the first image it finds on Google.
"mic drop.gif"!

image

Features

  • Listens for messages containing image file names (e.g., example.jpg, example.png, example.gif).
  • Searches for images on Google and sends the first result back to the user.
  • Supports both regular images and GIFs.

Prerequisites

  • Rust and Cargo installed on your system. You can install them from rustup.rs.
  • A Telegram bot token. You can create a bot and get a token by talking to BotFather on Telegram.

Setup

  1. Download Rust.
  2. Create a new bot using @Botfather to get a token in the format 123456789:blablabla.
  3. Initialise the TELOXIDE_TOKEN environmental variable to your token:
# Unix-like
$ export TELOXIDE_TOKEN=<Your token here>

# Windows command line
$ set TELOXIDE_TOKEN=<Your token here>

# Windows PowerShell
$ $env:TELOXIDE_TOKEN=<Your token here>
  1. Make sure that your Rust compiler is up to date (teloxide currently requires rustc at least version 1.80):
# If you're using stable
$ rustup update stable
$ rustup override set stable

# If you're using nightly
$ rustup update nightly
$ rustup override set nightly
  1. Build and run the project:

    cargo run

Usage

  • Start the bot on Telegram by searching for your bot's username and sending a message with an image file name (e.g., example.jpg).
  • The bot will respond with the first possible image result it finds.

Dependencies

  • Teloxide for Telegram bot API interaction.
  • Reqwest for making HTTP requests.
  • Regex for regular expression matching.
  • Anyhow for error handling.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

License

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

About

A bot reply first Google search image when you type "[something].jpg"

Resources

License

Stars

Watchers

Forks