Skip to content

Instantly share code, notes, and snippets.

View Enigo's full-sized avatar

Ruslan S. Enigo

View GitHub Profile
#!/bin/bash
SCRIPT_PATH=$(dirname $(realpath -s $0))
echo "Starting environment..."
docker-compose -p data-loader -f $SCRIPT_PATH/docker-compose.yaml up -d --build
echo
printf "Waiting for DB"
while ! curl http://localhost:5432/ 2>&1 | grep '52' > /dev/null ; do
printf "."
sleep 1
done
services:
db:
image: postgres:15.3
restart: 'no'
environment:
POSTGRES_PASSWORD: notsecure
POSTGRES_USER: data-loader-local
POSTGRES_DB: illuvium-land
ports:
- '5432:5432'
const USER_AGENT_VALUE: &str = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36";
pub async fn send(metadata: Metadata, buy: Buy) {
let message = build_message(&metadata, buy);
let bot = Bot::new(BOT_TOKEN);
let file_name = &format!("/tmp/{}.png", Alphanumeric.sample_string(&mut rand::thread_rng(), 16));
let path = Path::new(file_name);
match process_image(&metadata.image_url, path).await {
Ok(_) => {
const BOT_TOKEN: &str = <>; // insert value
const CHAT_ID: i64 = <>; // insert value
pub async fn send(metadata: Metadata, buy: Buy) {
let message = build_message(&metadata, buy);
let bot = Bot::new(BOT_TOKEN);
info!("Sending message to telegram");
match bot.send_message(ChatId(CHAT_ID), message).await
{
Ok(message) => info!("Text message sent successfully {:?}", message.id),
pub async fn read_orders() {
let response = fetch_api_response::<Order>(ORDERS_URL).await;
match response {
Ok(order) => {
info!("Processing order response");
let mut futures = vec![];
for result in order.result {
let future = task::spawn(process_order(result));
futures.push(future);
}
pub async fn read_orders() {
let response = fetch_api_response::<Order>(ORDERS_URL).await;
match response {
Ok(order) => {
info!("Processing order response");
for result in order.result {
process_order(result)
}
}
Err(e) => {
async fn process_order(result: TheResult) {
let timestamp = DateTime::parse_from_rfc3339(&result.timestamp).unwrap();
let for_last_minutes = 1;
let last_minute = Utc::now() - Duration::minutes(for_last_minutes);
let is_after = timestamp > last_minute;
if is_after {
info!("Newly listed land detected");
let response = reqwest::get(ASSET_URL.to_owned() + &result.sell.data.id)
.await.unwrap().json::<Asset>()
#[tokio::main]
pub async fn read_orders() {
let response = reqwest::get(ORDERS_URL)
.await.unwrap().json::<Order>()
.await;
match response {
Ok(order) => {
info!("Processing order response");
for result in order.result {
const ORDERS_URL: &str = "https://api.x.immutable.com/v1/orders?status=active&sell_token_address=0x9e0d99b864e1ac12565125c5a82b59adea5a09cd";
const ASSET_URL: &str = "https://api.x.immutable.com/v1/assets/0x9e0d99b864e1ac12565125c5a82b59adea5a09cd/";
pub fn read_orders() {
}
@Enigo
Enigo / main.rs
Last active January 9, 2023 02:19
use new_listing_api_reader::read_orders;
mod new_listing_api_reader;
mod model;
fn main() {
env_logger::init_from_env(
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"));
read_orders();
}