get irc working

master
lza_menace 2 years ago
parent e5b26432b6
commit bcbea81135

1
.gitignore vendored

@ -1,4 +1,5 @@
/target
/vendor
*.json
*.log
*.ogg

@ -1,118 +0,0 @@
:CTCPServ!services@services.oftc.net PRIVMSG wowboombox :VERSION:reflection.oftc.net NOTICE AUTH :*** Looking up your hostname...
:reflection.oftc.net NOTICE AUTH :*** Checking Ident
:reflection.oftc.net NOTICE AUTH :*** Couldn't look up your hostname
:reflection.oftc.net NOTICE AUTH :*** No Ident response
:reflection.oftc.net 001 wowboombox :Welcome to the OFTC Internet Relay Chat Network wowboombox
:reflection.oftc.net 002 wowboombox :Your host is reflection.oftc.net[64.86.243.183/6667], running version hybrid-7.2.2+oftc1.7.3
:reflection.oftc.net 003 wowboombox :This server was created Aug 9 2022 at 01:16:38
:reflection.oftc.net 004 wowboombox reflection.oftc.net hybrid-7.2.2+oftc1.7.3 CDGPRSabcdfgijklnorsuwxyz bciklmnopstvzeIMRS bkloveI
:reflection.oftc.net 005 wowboombox CALLERID CASEMAPPING=rfc1459 DEAF=D KICKLEN=160 MODES=4 NICKLEN=30 PREFIX=(ov)@+ STATUSMSG=@+ TOPICLEN=391 NETWORK=OFTC MAXLIST=beI:100 MAXTARGETS=1 CHANTYPES=# :are supported by this server
:reflection.oftc.net 005 wowboombox CHANLIMIT=#:250 CHANNELLEN=50 CHANMODES=eIqb,k,l,cimnpstzMRS AWAYLEN=160 KNOCK ELIST=CMNTU SAFELIST EXCEPTS=e INVEX=I :are supported by this server
:reflection.oftc.net 042 wowboombox 8L3AADHMZ :your unique ID
:reflection.oftc.net 251 wowboombox :There are 32 users and 30389 invisible on 19 servers
:reflection.oftc.net 252 wowboombox 20 :IRC Operators online
:reflection.oftc.net 253 wowboombox 18 :unknown connection(s)
:reflection.oftc.net 254 wowboombox 4069 :channels formed
:reflection.oftc.net 255 wowboombox :I have 1432 clients and 1 servers
:reflection.oftc.net 265 wowboombox :Current local users: 1432 Max: 2049
:reflection.oftc.net 266 wowboombox :Current global users: 30421 Max: 31889
:reflection.oftc.net 250 wowboombox :Highest connection count: 2050 (2049 clients) (149498 connections received)
:reflection.oftc.net 375 wowboombox :- reflection.oftc.net Message of the Day -
:reflection.oftc.net 372 wowboombox :- O
:reflection.oftc.net 372 wowboombox :- \ The Open and Free
:reflection.oftc.net 372 wowboombox :- O Technology Community
:reflection.oftc.net 372 wowboombox :- /| https://www.oftc.net
:reflection.oftc.net 372 wowboombox :- O-O O
:reflection.oftc.net 372 wowboombox :-
:reflection.oftc.net 372 wowboombox :- Welcome to the OFTC IRC Network.
:reflection.oftc.net 372 wowboombox :-
:reflection.oftc.net 372 wowboombox :- The Open and Free Technology Community was founded at the
:reflection.oftc.net 372 wowboombox :- end of 2001 by a group of experienced members of the Open
:reflection.oftc.net 372 wowboombox :- Source and Free Software communities; it is aimed at
:reflection.oftc.net 372 wowboombox :- providing these communities with better communication,
:reflection.oftc.net 372 wowboombox :- development, and support infrastructure. Our goal is to
:reflection.oftc.net 372 wowboombox :- provide stable services to members of the community in any
:reflection.oftc.net 372 wowboombox :- part of the world, while listening closely to their needs
:reflection.oftc.net 372 wowboombox :- and desires.
:reflection.oftc.net 372 wowboombox :-
:reflection.oftc.net 372 wowboombox :- We are not a general purpose chat platform, but a topical
:reflection.oftc.net 372 wowboombox :- network intent on providing the open source and free
:reflection.oftc.net 372 wowboombox :- software communities a means to cooperate and communicate.
:reflection.oftc.net 372 wowboombox :- As such, illegal and off-topic activity, such as warez
:reflection.oftc.net 372 wowboombox :- trading, will result in being barred from access.
:reflection.oftc.net 372 wowboombox :-
:reflection.oftc.net 372 wowboombox :- OFTC honors your privacy. To operate the network, we store
:reflection.oftc.net 372 wowboombox :- and process information about IRC connections, nicknames,
:reflection.oftc.net 372 wowboombox :- and channels. Our Privacy Policy explains what we do with
:reflection.oftc.net 372 wowboombox :- that data, and what your rights are. By connecting, you
:reflection.oftc.net 372 wowboombox :- accept these terms: https://www.oftc.net/Privacy_Policy/
:reflection.oftc.net 372 wowboombox :-
:reflection.oftc.net 372 wowboombox :- If you require assistance with using the OFTC IRC network,
:reflection.oftc.net 372 wowboombox :- stop by in channel #oftc, or email support@oftc.net with
:reflection.oftc.net 372 wowboombox :- details. For help with non-IRC questions please refer to
:reflection.oftc.net 372 wowboombox :- the respective channels and project homepages.
:reflection.oftc.net 372 wowboombox :-
:reflection.oftc.net 372 wowboombox :- Thanks and enjoy your stay! The OFTC team.
:reflection.oftc.net 376 wowboombox :End of /MOTD command.
:wowboombox!~wowboombo@47.209.29.77 MODE wowboombox :+i
:CTCPServ!services@services.oftc.net PRIVMSG wowboombox :VERSION
PING :reflection.oftc.net
ERROR :Closing Link: 47.209.29.77 (Ping timeout: 480 seconds)
:larich.oftc.net NOTICE AUTH :*** Looking up your hostname...
:larich.oftc.net NOTICE AUTH :*** Checking Ident
:larich.oftc.net NOTICE AUTH :*** Couldn't look up your hostname
:larich.oftc.net NOTICE AUTH :*** No Ident response
:larich.oftc.net 001 wowboombox :Welcome to the OFTC Internet Relay Chat Network wowboombox
:larich.oftc.net 002 wowboombox :Your host is larich.oftc.net[140.211.166.64/6667], running version hybrid-7.2.2+oftc1.7.3
:larich.oftc.net 003 wowboombox :This server was created Aug 9 2022 at 01:17:04
:larich.oftc.net 004 wowboombox larich.oftc.net hybrid-7.2.2+oftc1.7.3 CDGPRSabcdfgijklnorsuwxyz bciklmnopstvzeIMRS bkloveI
:larich.oftc.net 005 wowboombox CALLERID CASEMAPPING=rfc1459 DEAF=D KICKLEN=160 MODES=4 NICKLEN=30 PREFIX=(ov)@+ STATUSMSG=@+ TOPICLEN=391 NETWORK=OFTC MAXLIST=beI:100 MAXTARGETS=1 CHANTYPES=# :are supported by this server
:larich.oftc.net 005 wowboombox CHANLIMIT=#:250 CHANNELLEN=50 CHANMODES=eIqb,k,l,cimnpstzMRS AWAYLEN=160 ELIST=CMNTU SAFELIST KNOCK EXCEPTS=e INVEX=I :are supported by this server
:larich.oftc.net 042 wowboombox 9O6AABAIY :your unique ID
:larich.oftc.net 251 wowboombox :There are 33 users and 30362 invisible on 19 servers
:larich.oftc.net 252 wowboombox 20 :IRC Operators online
:larich.oftc.net 253 wowboombox 28 :unknown connection(s)
:larich.oftc.net 254 wowboombox 4068 :channels formed
:larich.oftc.net 255 wowboombox :I have 1087 clients and 1 servers
:larich.oftc.net 265 wowboombox :Current local users: 1087 Max: 1118
:larich.oftc.net 266 wowboombox :Current global users: 30395 Max: 31261
:larich.oftc.net 250 wowboombox :Highest connection count: 1119 (1118 clients) (46969 connections received)
:larich.oftc.net 375 wowboombox :- larich.oftc.net Message of the Day -
:larich.oftc.net 372 wowboombox :- O
:larich.oftc.net 372 wowboombox :- \ The Open and Free
:larich.oftc.net 372 wowboombox :- O Technology Community
:larich.oftc.net 372 wowboombox :- /| https://www.oftc.net
:larich.oftc.net 372 wowboombox :- O-O O
:larich.oftc.net 372 wowboombox :-
:larich.oftc.net 372 wowboombox :- Welcome to the OFTC IRC Network.
:larich.oftc.net 372 wowboombox :-
:larich.oftc.net 372 wowboombox :- The Open and Free Technology Community was founded at the
:larich.oftc.net 372 wowboombox :- end of 2001 by a group of experienced members of the Open
:larich.oftc.net 372 wowboombox :- Source and Free Software communities; it is aimed at
:larich.oftc.net 372 wowboombox :- providing these communities with better communication,
:larich.oftc.net 372 wowboombox :- development, and support infrastructure. Our goal is to
:larich.oftc.net 372 wowboombox :- provide stable services to members of the community in any
:larich.oftc.net 372 wowboombox :- part of the world, while listening closely to their needs
:larich.oftc.net 372 wowboombox :- and desires.
:larich.oftc.net 372 wowboombox :-
:larich.oftc.net 372 wowboombox :- We are not a general purpose chat platform, but a topical
:larich.oftc.net 372 wowboombox :- network intent on providing the open source and free
:larich.oftc.net 372 wowboombox :- software communities a means to cooperate and communicate.
:larich.oftc.net 372 wowboombox :- As such, illegal and off-topic activity, such as warez
:larich.oftc.net 372 wowboombox :- trading, will result in being barred from access.
:larich.oftc.net 372 wowboombox :-
:larich.oftc.net 372 wowboombox :- OFTC honors your privacy. To operate the network, we store
:larich.oftc.net 372 wowboombox :- and process information about IRC connections, nicknames,
:larich.oftc.net 372 wowboombox :- and channels. Our Privacy Policy explains what we do with
:larich.oftc.net 372 wowboombox :- that data, and what your rights are. By connecting, you
:larich.oftc.net 372 wowboombox :- accept these terms: https://www.oftc.net/Privacy_Policy/
:larich.oftc.net 372 wowboombox :-
:larich.oftc.net 372 wowboombox :- If you require assistance with using the OFTC IRC network,
:larich.oftc.net 372 wowboombox :- stop by in channel #oftc, or email support@oftc.net with
:larich.oftc.net 372 wowboombox :- details. For help with non-IRC questions please refer to
:larich.oftc.net 372 wowboombox :- the respective channels and project homepages.
:larich.oftc.net 372 wowboombox :-
:larich.oftc.net 372 wowboombox :- Thanks and enjoy your stay! The OFTC team.
:larich.oftc.net 376 wowboombox :End of /MOTD command.
:wowboombox!~wowboombo@47.209.29.77 MODE wowboombox :+i
:CTCPServ!services@services.oftc.net PRIVMSG wowboombox :VERSION

@ -7,6 +7,7 @@ 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 {
@ -77,6 +78,82 @@ impl eframe::App for App {
});
ui.separator();
ui.heading(egui::RichText::new("WOW!Radio").color(egui::Color32::WHITE));
ui.label(egui::RichText::new("Your home for the most diabolical playlist of the century, made by the skeevers, scallywags, chupacabras, snails, and whores of the Wownero community. Join da chat to peep da scoop.\n").color(egui::Color32::WHITE));
ui.horizontal(|ui| {
if self.player.playing {
if ui.button("⏸").clicked() {
let _ = &self.player.sink.pause();
self.player.playing = false;
}
ui.add(egui::Slider::new(&mut self.player.volume, 0.0..=100.0));
self.player.sink.set_volume(self.player.volume / 100.0);
if self.player.sink.len() != 1 {
// let _ = self.player.wait_for_source();
let f = std::fs::File::open(crate::RADIO_STREAM);
if let Ok(fo) = f {
let file = std::io::BufReader::new(fo);
let source = rodio::Decoder::new(file);
if source.is_err() {
return ()
}
// let _ = self.player.sink.stop();
let _ = self.player.sink.append(source.unwrap());
let _ = self.player.sink.play();
} else {
return ()
}
}
} else {
if ! self.tor_connected && self.tor_required {
ui.label("Connect to the Tor network first.");
} else {
if ui.button("▶").clicked() {
if ! self.tor_connected && self.tor_required {
return ();
}
// If stream thread is done, start again
if self.player.stream_thread.is_finished() {
self.player.stream_thread = self.player.start_radio_stream(self.tor_required);
}
let _ = self.player.sink.play();
self.player.playing = true;
}
}
}
});
// Show spinner when downloading, along with file size
if ! self.player.stream_thread.is_finished() {
ui.horizontal(|ui| {
ui.spinner();
let size: u64 = self.player.get_radio_size();
ui.label(format!(
"{:?} -> {} ({} bytes)",
self.player.stream_source,
crate::RADIO_STREAM,
size
));
});
}
// Show exif metadata when radio file available to read
if self.player.playing && self.player.get_radio_size() > 0 {
let rt = egui::RichText::new(
format!("\n{:?}", self.player.stream_exif))
.color(egui::Color32::WHITE)
.size(18.0);
ui.label(rt);
let dur = self.player.exif_date.elapsed().unwrap();
if dur > Duration::from_secs(15) {
self.player.exif_date = SystemTime::now();
self.player.stream_exif = self.player.get_song_meta().unwrap();
}
}
ui.separator();
// Tor
if self.tor_required {
if self.tor_started {
ui.label(
@ -103,10 +180,17 @@ impl eframe::App for App {
self.irc.run().expect("wtf mate");
self.irc_connected = true;
} else if self.show_irc {
egui::ScrollArea::vertical().show(ui, |ui| {
egui::ScrollArea::vertical().stick_to_bottom(true).show(ui, |ui| {
ui.label(self.irc.read_irc_log());
ui.text_edit_singleline(&mut self.irc_message);
if ui.button("> Send <").clicked() {
// send_cmd(self.irc.)
self.irc_message = "".to_owned();
}
});
}
// Market
if self.show_market_data {
egui::ComboBox::from_label("Pick currency base.")
.selected_text(format!("{}", self.market.denomination))
@ -157,83 +241,5 @@ impl eframe::App for App {
}
});
// Show volume controls
egui::TopBottomPanel::bottom("radio_player").show(ctx, |ui| {
ui.heading(egui::RichText::new("WOW!Radio").color(egui::Color32::WHITE));
ui.label(egui::RichText::new("Your home for the most diabolical playlist of the century, made by the skeevers, scallywags, chupacabras, snails, and whores of the Wownero community. Join da chat to peep da scoop.\n").color(egui::Color32::WHITE));
ui.horizontal(|ui| {
if self.player.playing {
if ui.button("⏸").clicked() {
let _ = &self.player.sink.pause();
self.player.playing = false;
}
ui.add(egui::Slider::new(&mut self.player.volume, 0.0..=100.0));
self.player.sink.set_volume(self.player.volume / 100.0);
if self.player.sink.len() != 1 {
// let _ = self.player.wait_for_source();
let f = std::fs::File::open(crate::RADIO_STREAM);
if let Ok(fo) = f {
let file = std::io::BufReader::new(fo);
let source = rodio::Decoder::new(file);
if source.is_err() {
return ()
}
// let _ = self.player.sink.stop();
let _ = self.player.sink.append(source.unwrap());
let _ = self.player.sink.play();
} else {
return ()
}
}
} else {
if ! self.tor_connected && self.tor_required {
ui.label("Connect to the Tor network first.");
} else {
if ui.button("▶").clicked() {
if ! self.tor_connected && self.tor_required {
return ();
}
// If stream thread is done, start again
if self.player.stream_thread.is_finished() {
self.player.stream_thread = self.player.start_radio_stream(self.tor_required);
}
let _ = self.player.sink.play();
self.player.playing = true;
}
}
}
});
// Show spinner when downloading, along with file size
if ! self.player.stream_thread.is_finished() {
ui.horizontal(|ui| {
ui.spinner();
let size: u64 = self.player.get_radio_size();
ui.label(format!(
"{:?} -> {} ({} bytes)",
self.player.stream_source,
crate::RADIO_STREAM,
size
));
});
}
// Show exif metadata when radio file available to read
if self.player.playing && self.player.get_radio_size() > 0 {
let rt = egui::RichText::new(
format!("\n{:?}", self.player.stream_exif))
.color(egui::Color32::WHITE)
.size(18.0);
ui.label(rt);
let dur = self.player.exif_date.elapsed().unwrap();
if dur > Duration::from_secs(15) {
self.player.exif_date = SystemTime::now();
self.player.stream_exif = self.player.get_song_meta().unwrap();
}
}
ui.label("");
});
}
}

@ -17,11 +17,10 @@ use std::thread;
/// # Arguments
///
/// * `nick` - A string that holds the desired user nickname.
/// # `server` - A string that holds the desired irc server
///
/// # Example
///
/// `let stream = connect(nick.to_owned(), server.to_owned()).unwrap();`
/// `let stream = connect(nick.to_owned()).unwrap();`
///
fn connect(nick: String) -> std::io::Result<TcpStream> {
// https://doc.rust-lang.org/std/net/struct.TcpStream.html
@ -35,7 +34,8 @@ fn connect(nick: String) -> std::io::Result<TcpStream> {
send_cmd(&send_stream, "USER", user_string)?;
send_cmd(&send_stream, "NICK", nick_string)?;
// send_cmd(&send_stream.get_ref(), "JOIN", "#wownero-music".to_owned())?;
send_cmd(&send_stream, "JOIN", format!("#wownero\r\n"))?;
send_cmd(&send_stream, "JOIN", format!("#wownero-music\r\n"))?;
Ok(send_stream)
}
@ -51,7 +51,7 @@ fn connect(nick: String) -> std::io::Result<TcpStream> {
///
/// `send_cmd(&send_stream, "QUIT", "\r\n".to_string())?;`
///
fn send_cmd(mut stream: &TcpStream, cmd: &str, msg: String) -> Result<usize, std::io::Error> {
pub fn send_cmd(mut stream: &TcpStream, cmd: &str, msg: String) -> Result<usize, std::io::Error> {
let mut cmd = cmd.to_string();
cmd.push_str(" ");
cmd.push_str(&msg);