Crates.io | omegalul |
lib.rs | omegalul |
version | 0.1.4 |
source | src |
created_at | 2021-08-27 03:37:52.896343 |
updated_at | 2021-08-28 00:40:55.569398 |
description | A simple library for building Omegle clients |
homepage | |
repository | |
max_upload_size | |
id | 442881 |
size | 40,751 |
omegalul-rs
is a work-in-progress opensource library for building Omegle clients.
These is just a simple example usage, to find more example usages, visit the
/examples
directory. For more documentation, check out the documentation
#[tokio::main]
async fn main() {
// get a random server to connect with, this server
// is grabbed from the https://omegle.com/status path.
if let Some(server_name) = get_random_server().await {
println!("Connecting to {} server", server_name);
// just create a new server - this is a simple struct and
// the Server::new(&str) method does nothing besides creating
// a new object of the struct.
let server = &mut Server::new(server_name.as_str(), vec!["hors".to_string(), "discord".to_string()]);
// start the chat, this sends a POST message
// and connects to the current omegle server
let chat = &mut server.start_chat().await;
if let Some(chat) = chat {
// indefinite loop to always get new events
// from the current omegle chat.
loop {
// fetch the current event, this may return
// a ChatEvent::None value - this means
// there is no current event going on.
let event = chat.fetch_event().await;
match event {
ChatEvent::Message(message) => println!("{}", &message),
ChatEvent::Disconnected => println!("The user has disconnected... mean."),
ChatEvent::Typing => println!("The user is typing... how exciting!"),
_ => ()
}
}
}
}
}