improve irc ux

master
lza_menace 2 years ago
parent bcbea81135
commit 4dd30a4d39

@ -7,7 +7,6 @@ use crate::player::Player;
use crate::tor::GuiTor;
use crate::stats::Market;
use crate::irc::Client as IRCClient;
use crate::irc::send_cmd;
use libtor::Error as libtorError;
pub struct App {
@ -150,6 +149,9 @@ impl eframe::App for App {
self.player.exif_date = SystemTime::now();
self.player.stream_exif = self.player.get_song_meta().unwrap();
}
if ui.button("!tune - i love this song!").clicked() {
let _ = self.irc.send_tune();
}
}
ui.separator();

@ -92,6 +92,9 @@ fn receive(mut stream: &TcpStream) -> std::io::Result<()> {
match res_string {
Ok(r) => {
if !res_string.unwrap().is_empty() {
if std::fs::File::open("irc.log").is_err() {
let _ = std::fs::write("irc.log", "");
}
let mut f = OpenOptions::new()
.append(true)
.open("irc.log")
@ -199,6 +202,14 @@ impl Client {
return s;
}
pub fn send_tune(&self) -> std::io::Result<()> {
let mut stream = connect(self.nick.to_owned())?;
thread::spawn(move || {
let _ = stream.write(b"PRIVMSG #wownero-music !tune\r\n");
});
Ok(())
}
/// Creates a send and recv TcpStream (with the same socket)
/// spins recv to its own thread
/// main thread takes user input and matches it to commands