3 unstable releases

0.2.0 Jun 14, 2024
0.1.2 Jun 12, 2024
0.1.1 Jun 12, 2024
0.1.0 Jun 12, 2024

#1611 in Command line utilities

Download history 1/week @ 2024-09-17 5/week @ 2024-09-24 3/week @ 2024-10-01

130 downloads per month

MIT license

24KB
434 lines

photo-2024-04-08-10-51-03-removebg-preview

Telitairos Bot


A fully functional AI Powered Telegram bot.

🦀

Setup guide

  1. Install Rust with rustup.
  2. Create a Telegram bot with @BotFather and get the token
  3. Create an OpenAI API Platform account and get both API Token and Organization Id
  4. Add environment variables
- TELOXIDE_TOKEN= "/* Your Telegram Bot API Key */"
- OPENAI_API_KEY= "/* Your OpenAI API Key */"
- OPENAI_ORG_ID= "/* Your OpenAI Organization ID */"
  1. Put these lines into your Cargo.toml
[dependencies]
telitairos-bot = "0.1.2"
teloxide = { version = "0.12", features = ["macros"] }
log = "0.4"
pretty_env_logger = "0.4"
tokio = { version =  "1.8", features = ["rt-multi-thread", "macros"] }

Supported commands

You can do either:

👮🚨 ADMIN Commands

  • /mute X {h/m/s/p} -> Mute an User from the Chat Group the selected time. 'p' is for 'permanent'
  • /ban X {h/m/s/p} -> Ban an User from the Chat Group the selected time. 'p' is for 'permanent'

🦀 AI Commands

  • /ask for a specified question.
  • /mediate to read the last N messages of a chat group and mitigate an argument.

Basic usage

TelitairoBot struct implements Default trait, so you can start a bot with a generic personality by just doing this:

let telitairo_bot = TelitairoBot::default();

Or partially initialize it like this:

let telitairo_bot = TelitairoBot {
  personality: String::from("You are a Victorian era, tea addicted assistant"),
  ..Default::default(),
}

If you want to set your own parameters, you need to specify the personality of the bot as well as its criteria when mitigating an argument. A size for the context of the N last messages of the chat group is also needed.

For a detailed example go to TelitairoBot

Example

#[tokio::main]
async fn main() {
   pretty_env_logger::init();
   log::info!("Starting bot");

   let telitairo_bot = TelitairoBot::new(
       String::from(/*Personality */),
       String::from(/* Mediation criteria */),
       /*size */,
   );

   telitairo_bot.dispatch().await;
}

Dependencies

~16–30MB
~470K SLoC