Separated bot

This commit is contained in:
2026-08-06 08:09:17 +02:00
parent e241b2e364
commit ce923c4438
2 changed files with 63 additions and 24 deletions
+4 -24
View File
@@ -1,10 +1,9 @@
pub mod account;
pub mod bot;
pub mod executor;
pub mod types;
use futures_util::{SinkExt, StreamExt};
use serde_json::json;
use tokio_tungstenite::connect_async;
use crate::bot::Bot;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
@@ -12,26 +11,7 @@ async fn main() -> anyhow::Result<()> {
builder.filter_level(log::LevelFilter::Info);
builder.init();
let (mut ws, _) = connect_async("wss://pumpdev.io/ws").await?;
let mut bot = Bot::new().await?;
ws.send(tokio_tungstenite::tungstenite::Message::Text(
json!({ "method": "subscribeNewToken" }).to_string().into(),
))
.await?;
while let Some(msg) = ws.next().await {
let msg = msg?;
if let tokio_tungstenite::tungstenite::Message::Text(text) = msg {
match serde_json::from_str::<types::PumpDevEvent>(&text) {
Ok(event) => {
println!("{:?}", event);
}
Err(err) => {
log::error!("{err}");
}
}
}
}
Ok(())
bot.start().await
}