A Discord bot to send updates on queries in tori.fi

Overview

torimies-rs

How the bot works?

The bot works by making requests to the undocumented (and very bad) tori.fi api endpoint. The users can add and remove new vahti-entries for themselves. Those are stored in the sqlite-database of the bot. The bot then goes through all of the defined vahtis in the database and sends the updates to the users accordingly.

How to host?

Make sure your .env includes all the necessary stuff:

  • DATABASE_URL=sqlite:database.sqlite (unless you change the location)
  • DISCORD_TOKEN=YourToken
  • APPLICATION_ID=YourAppID
  • UPDATE_INTERVAL=time_in_seconds (defaults to 60)

Setting up the database

Before running you need to setup the sqlite-database

I do this with the sqlx-cli tool.

The tool is installed with cargo install sqlx-cli

After that you can just run the reset_db.sh script after which your database should be good to go.

The binary builds include a pre-initialize database :)

Running torimies-rs

If you are building from source, just do cargo run --release in the root of the repository

If you are are using a binary build, just do ./torimies-rs

Using the bot

The bot has two main commands implemented as application commands (slash-commands) and those are:

  • /vahti url Add a new vahti with the specified url
  • /poistavahti url Remove the vahti with the specified url

One additional owner-commmand is also included:

  • !update_all_vahtis to well... update all vahtis :D.

Please mind that the bot is still considered to be WIP. We will gladly accept any feedback/feature requests :), just file an issue and we'll look into it

Comments
  • Create Docker build instructions

    Create Docker build instructions

    Implemented dockerfile, entrypoint.sh and docker-compose.yml. Now torimies-rs can be started with simple command docker-compose up -d and rebuilt with docker-compose up -d --build.

    opened by RoyTakanen 5
  • Add slash to the end of the validation url

    Add slash to the end of the validation url

    This will prevent a user from using a url such as https://www.tori.fi.localhost/?.

    Currently if a user used that example url, it wouldn't be a vulnerability. However, if in the future the url was used as-is without any sanitization (not sure why that would happen, but never say never), then it could create a vulnerability such as SSRF.

    bug 
    opened by Eldemarkki 2
  • Add support for mobile-urls

    Add support for mobile-urls

    The urls look similar to this: https://m.tori.fi/li?he=1&ca=18&sp=0&fmy=0&q=palvelin&cg=5030&w=118&c=5042&st=s&f=a&ps=&pe=

    enhancement 
    opened by lajp 2
  • "Database is already locked" Error shows when trying to refresh too many Vahtis at once

    This is critical because it prevents the bot from refreshing the vahtis and therefore sending the users their notifications. This is because SQLite does not support concurrent writes.

    A workaround can be found here: https://stackoverflow.com/questions/57123453/how-to-use-diesel-with-sqlite-connections-and-avoid-database-is-locked-type-of

    bug 
    opened by lajp 1
  • Make `/poistaesto` and `/poistavahti` and similar ephemeral

    Make `/poistaesto` and `/poistavahti` and similar ephemeral

    This should be fixed because the buttons/menus are usable by all the users that see the message and therefore anyone can unblock sellers or remove vahtis from the command user unless they use it in the DMs with the bot.

    bug good first issue 
    opened by lajp 0
  • Add support for huuto.net

    Add support for huuto.net

    This adds support for the huuto.net website that works very similarly to tori.fi The thing that is cool about huuto.net is that their API is documented here

    This PR aims to be future-proof and will make the implementation of other websites easier.

    enhancement 
    opened by lajp 0
  • reset-db.sh not working on some machines

    reset-db.sh not working on some machines

    This is weird. Some machines require the --database-url while other machines can't stand it.

    Perhaps something along the lines of sqlx database setup --database-url sqlite:database.sqlite || sqlx database setup could work

    bug 
    opened by lajp 0
  • Add verification for vahti urls.

    Add verification for vahti urls.

    At the moment, the search-urls provided by the users are not checked at all. Perhaps a mechanism that allows a vahti to only be placed for a search that has results would be a good solution...

    enhancement 
    opened by lajp 0
  • Support for

    Support for "Autot" search

    Helloes,

    When trying to use url of "Hae Autoja" in Vahti, error appears that its not valid url so the Vahti will not be created.

    example url: https://autot.tori.fi/vaihtoautot/audi?hinta-max=1000

    I would like to have it implemented to vahti command, or perhaps to be able to create autovahti's also.

    Thanks!

    enhancement help wanted 
    opened by jahidev 1
  • Optimization

    Optimization

    If two or more users have a tracker for same keyword but different regions, then just request all entries for that keyword in the whole country and do the region filtering in the code. This would make the bot more scalable (at least a little bit) because the amount of requests can go down somewhat huge amounts due to specific keywords being used more often (Thinkpad) than others.

    enhancement 
    opened by faitti 0
  • Write some tests

    Write some tests

    While the codebase is maturing and getting larger and more feature-full everyday it is starting to become more and more apparent than in order to guarantee the stability of the main branch and the codebase in general, we need to have a test-suite that must be run on every commit and pull-request.

    In general it would make it easier for us maintainers to well maintain the repository and more difficult for everyone to "push bad code"

    In addition to this, some kind of auto-formatting using cargo fmt would be nice too in order to maintain readability.

    help wanted high priority 
    opened by lajp 0
Releases(v0.1.5)
  • v0.1.5(Jan 7, 2022)

  • v0.1.4(Dec 18, 2021)

    This release includes various super-cool-and-nice new features:

    • Seller blacklist
    • Visual improvements to the embeds (more buttons)
    • Illegally-fast scheduling
    • Migration from sqlx (bad) to diesel (good)
    • major codebase cleanup

    Also: this has been built with musl, which means it should support even more machines (only x86_64 tho :/)

    Source code(tar.gz)
    Source code(zip)
    torimies-0.1.4.tar.xz(8.29 MB)
  • v0.1.3(Nov 24, 2021)

  • v0.1.2(Nov 21, 2021)

  • v0.1.1(Nov 16, 2021)

    Stuff that changed

    • Vahti-urls are now verified before added
    • The update-interval is now adjustable in .env
    • The regional search-filter should finally be working

    The executable has been build on Debian Buster using the nightly toolchain (this means that it depends on glibc >= 2.31.1)

    Source code(tar.gz)
    Source code(zip)
    torimies-0.1.1.tar.gz(6.58 MB)
  • v0.1.0(Nov 15, 2021)

Owner
Testausserveri ry
Community of young Finnish hackers
Testausserveri ry
A Discord bot focused on addressing the inherent problems with Discord, to allow a more socialist/anarchist organization of servers.

ACABot A Discord bot focused on addressing the inherent problems with Discord, to allow a more socialist/anarchist organization of servers (or "guilds

null 4 May 3, 2022
A rust(serenity) based discord bot for the hacksquad discord server

A Discord Bot for Hacksquad How to Deploy? Requirements Docker Docker Compose Steps To Run Copy the docker-compose.yml and .env.example files to your

HackSquad 5 Jan 4, 2023
Rewrite of the Discord Bot used for Managing the Infinity Bot List Servers.

Arcadia Rewrite of the Discord Bot used for Managing the Infinity Bot List Servers. Contributing Always run fmt.sh before making a Pull Request! MacOS

InfinityBotList 3 Dec 15, 2022
A simple bot for discord.

Rusky Um simples bot para o discord! ?? Executando ⚠️ Antes de tudo você precisa do Rust Instalado você pode instalar clicando aqui Preparando Primeir

Rusky 3 Aug 12, 2022
A Discord bot for lichess and Rosen related things

liro Liro is a Discord bot that follows in the footsteps of Lichess-discord-bot, without necessarily aiming to replace it. The main pain point that th

Sebastian Lauwers 5 Feb 16, 2022
Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (❁´◡`❁)

Sophy Bot Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (❁´◡`❁) Contribution Do you like me and want to help me?

Far Dragi 0 May 30, 2022
A Discord bot for sending GeoGuessr challenge links that uses the GeoGuessr API written in rust.

GeoGuessr-bot-rs This is a simple implementation of a discord bot that send GeoGuessr-challenge links on demand. Features: Slash-commands Lightning-fa

Luukas Pörtfors 6 Nov 18, 2022
🦴🤖 // A Discord bot about collecting all the Borpa

?? ?? Borpa Bot Borpa Bot is a Discord bot about collecting all the Borpa possible. If you dont know what a Borpa is you can find it here Crate Descri

mellowmarshe 1 Dec 19, 2021
A scriptable discord bot (WIP)

Status This project is currently a VERY EARLY WORK IN PROGRESS. Contact me on discord for more details: Jonas747#0001 (105487308693757952) BotLoader (

null 26 Dec 21, 2022
🦜 A hassle-free, highly performant, host it yourself Discord music bot built with Serenity in Rust. Powered by youtube-dl and Genius.

?? A hassle-free, highly performant and fast evolving Discord music bot built with Serenity in Rust. Deployment Usage Just create a bot account, copy

Miguel Mano 82 Dec 14, 2022
The best discord bot to annoy @a3mat

A3mat v pomoyke The best discord bot to annoy @a3mat Usage: This command moves pinged users n times: move <number> [users...] This command moves ping

null 1 Dec 31, 2021
A Discord bot for control and decentralization of threads management

Threadripper-bot A Discord bot for control and decentralization of threads management About Threadripper aims to serve some extra utilities to take be

S0ra 15 Dec 27, 2022
A small in-house bot of the TTC Discord Server

Welcome to The Terminal cafe Support Bot Repository Hello, hope you are having a nice day. This is the official repository for The Terminal Cafe Suppo

null 5 Jul 4, 2022
A discord bot that safely executes whatever rust you throw at it. Remote code execution as a service

RustBot Bot is still under development and not ready for production use RustBot is a discord bot that executes whatever rust code you throw at it. In

Conner Bradley 7 Jan 3, 2022
An experimental Discord bot using Serenity.

VoidBot An experimental Discord bot using Serenity. Environment Variables Can be set with a .env file. DISCORD_TOKEN: The token for your bot. (require

null 1 May 21, 2022
Yet another multi-purpose discord bot

virus yet another multi-purpose discord bot

miten 2 Jan 11, 2022
sentry - yet another multi-purpose discord bot

sentry - yet another multi-purpose discord bot

miten 1 Feb 17, 2022
This is a Discord bot written in Rust to translate to and from the Bottom Encoding Standard using bottom-rs and Serenity.

bottom-bot This is a Discord bot written in Rust to translate to and from the Bottom Encoding Standard using bottom-rs and Serenity. Ever had this pro

Bottom Software Foundation 11 Dec 10, 2022
Discord bot for the Tegaki Tuesday handwriting challenge 🚧 WIP NOT PRODUCTION 🚧

字(じ)ちゃん 字(じ)ちゃん is the Discord bot for the Tegaki Tuesday handwriting challenge. For more information on the challenge, please visit the website. She

Elnu 0 Dec 19, 2022