messages from server over 4k charcters are now cut to only 4k
This commit is contained in:
@@ -32,4 +32,5 @@ Check the template for details about each setting
|
|||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
- Better error handling
|
- Better error handling
|
||||||
- handle large responses from mindus server
|
- handle large responses from mindus server
|
||||||
|
- make things modular
|
||||||
|
|||||||
@@ -67,11 +67,13 @@ async fn main() {
|
|||||||
.await
|
.await
|
||||||
.expect("Error creating client");
|
.expect("Error creating client");
|
||||||
|
|
||||||
|
println!("Discord Bot Connected!!");
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut data = client.data.write().await;
|
let mut data = client.data.write().await;
|
||||||
data.insert::<TcpSock>(sock);
|
data.insert::<TcpSock>(sock);
|
||||||
data.insert::<Config>(conf)
|
data.insert::<Config>(conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(why) = client.start().await {
|
if let Err(why) = client.start().await {
|
||||||
println!("An error occurred while running the client: {:?} \n Check that there is a bot token set in config", why);
|
println!("An error occurred while running the client: {:?} \n Check that there is a bot token set in config", why);
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ pub struct TcpSock {
|
|||||||
impl TcpSock {
|
impl TcpSock {
|
||||||
pub fn new(ip: String, port: String) -> std::io::Result<Self> {
|
pub fn new(ip: String, port: String) -> std::io::Result<Self> {
|
||||||
let stream = TcpStream::connect(format!("{}:{}", ip, port)).expect("Tcp connection fail");
|
let stream = TcpStream::connect(format!("{}:{}", ip, port)).expect("Tcp connection fail");
|
||||||
stream.set_read_timeout(Some(Duration::from_millis(200)))?;
|
stream.set_read_timeout(Some(Duration::from_millis(25)))?;
|
||||||
|
println!("Socket Connected!!");
|
||||||
Ok(TcpSock { stream })
|
Ok(TcpSock { stream })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,15 +60,14 @@ pub fn cons_rw(sock: &TcpSock, input: &str) -> String {
|
|||||||
Err(_) => break(),
|
Err(_) => break(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
println!("{}", output);
|
|
||||||
output = String::from_utf8(strip_ansi_escapes::strip(&output).unwrap()).unwrap();
|
output = String::from_utf8(strip_ansi_escapes::strip(&output).unwrap()).unwrap();
|
||||||
|
output.truncate(4000);
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn init_conf() -> Config {
|
pub async fn init_conf() -> Config {
|
||||||
|
|
||||||
|
|
||||||
let mut toml_file = OpenOptions::new()
|
let mut toml_file = OpenOptions::new()
|
||||||
.read(true)
|
.read(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
@@ -79,13 +78,12 @@ pub async fn init_conf() -> Config {
|
|||||||
|
|
||||||
toml_file.read_to_string(&mut toml_str).unwrap();
|
toml_file.read_to_string(&mut toml_str).unwrap();
|
||||||
|
|
||||||
println!("{}", toml_str);
|
|
||||||
|
|
||||||
let config: Config = toml::from_str(&toml_str).expect("unable to fill Config struct");
|
let config: Config = toml::from_str(&toml_str).expect("unable to fill Config struct");
|
||||||
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn toml_make() -> File {
|
fn toml_make() -> File {
|
||||||
println!("initializing config");
|
println!("initializing config");
|
||||||
let mut toml_file = OpenOptions::new()
|
let mut toml_file = OpenOptions::new()
|
||||||
|
|||||||
Reference in New Issue
Block a user