- Install Rust with rustup.
- Create a Telegram bot with @BotFather and get the token
- Create an OpenAI API Platform account and get both API Token and Organization Id
- Add environment variables
- TELOXIDE_TOKEN= "/* Your Telegram Bot API Key */"
- OPENAI_API_KEY= "/* Your OpenAI API Key */"
- OPENAI_ORG_ID= "/* Your OpenAI Organization ID */"
- 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"] }
You can do either:
/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'
/ask
for a specified question./mediate
to read the last N messages of a chat group and mitigate an argument.
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
#[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;
}