peach-tbot/src/main.rs

33 lines
741 B
Rust
Raw Normal View History

2020-11-05 21:32:12 +00:00
use std::env;
use dotenv;
use futures::StreamExt;
use telegram_bot::*;
2020-11-18 17:22:48 +00:00
use telegram_bot::{Api, Message, SendMessage, MessageKind, UpdateKind};
2020-11-19 12:27:13 +00:00
mod tele;
use tele::TStruct;
use std::result::Result;
use std::{thread, time};
2020-11-18 17:22:48 +00:00
2020-11-05 21:32:12 +00:00
2021-04-20 13:48:24 +00:00
2020-11-05 21:32:12 +00:00
#[tokio::main]
async fn main() -> Result<(), Error> {
2021-04-20 13:48:24 +00:00
dotenv::from_path("/etc/peachtbot.conf").ok();
2020-11-05 21:32:12 +00:00
let token = env::var("TELEGRAM_BOT_TOKEN").expect("TELEGRAM_BOT_TOKEN not set");
let api = Api::new(token);
2020-11-18 17:22:48 +00:00
let telegram_log_id: i64 = env::var("TELEGRAM_LOG_ID").expect("TELEGRAM_LOG_ID is not set").parse().unwrap();
2020-11-19 12:27:13 +00:00
let t: TStruct = TStruct::new(api, telegram_log_id);
t.test();
2021-04-20 13:48:24 +00:00
t.log("++ peach-tbot is online").await?;
2020-11-19 12:27:13 +00:00
2021-04-20 13:48:24 +00:00
t.log_ip().await?;
t.poll().await?;
2020-11-05 21:32:12 +00:00
Ok(())
}