mod console; mod command; use command::{ChatMessage, Command}; use rcon::{Connection, Error}; use std::{net::{SocketAddr}, path::{Path, PathBuf}, sync::mpsc, time::Duration}; use tokio::net::TcpStream; use notify::{Event, RecursiveMode, Result, Watcher}; use clap::Parser; use console::Console; // const log_file : Path = Path::new ( // "~/.local/share/Steam/steamapps/common/Team Fortress 2/tf/console.log" // ); /// Larp as Wiktionary in TF2's in-game chat. #[derive(Parser, Debug)] #[command( name = "wiktlarp", version, about, long_about, )] struct Args { /// Path to TF2's console log #[clap( value_parser, long, short='f', default_value=console::default_log_file ().into_os_string () )] log_file: PathBuf, /// RCON address to send chat commands to #[clap( value_parser, long, short='a', default_value="127.0.0.1:27015" )] rcon_address: SocketAddr, /// RCON password #[clap(value_parser,long,short='p',default_value="monitor")] rcon_password: String, } #[tokio::main] async fn main () -> Result<()> { let args = Args::parse (); println! ("{:?}", args); let mut client = >::builder () .connect (args.rcon_address.to_string (), &args.rcon_password) .await.unwrap (); Console::watch ( &args.log_file, |line| { println! ("line: {line}"); let Some (msg) = ChatMessage::parse (line) else { return }; let Some (cmd) = Command::parse (&msg) else { return }; println! ("cmd: {:?}", cmd); } )?; Ok (()) }