Skip to content

Snaze878/RBR_Bot_MySQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌟 RBR Discord Bot (MySQL Edition)

Welcome to the RBR Discord Bot (MySQL Edition)! This bot scrapes online leaderboards from rallysimfans.hu and posts real-time updates to Discord, powered by MySQL integration and advanced stat tracking.


🏎️ Features

  • Automated Leaderboard Updates – Scrapes and posts latest standings directly to Discord.
  • Live Leader Change Detection – Announces when drivers take the lead in any rally stage.
  • MySQL 8.0 Database Backend – All data logged asynchronously using aiomysql.
  • Interactive Dropdowns – Easily choose drivers or weeks using Discord UI.
  • Google Sheets Integration – Syncs rally configs from Google Form submissions.
  • Admin-Only Controls – Run syncs, rescrapes, restarts, and more.
  • Stats, Trends & History – Track performance over time, podiums, and car usage.
  • Stage Completion Breakdown – Shows who has/haven't completed each stage.
  • Stage Win Tracker – Highlights most successful drivers per stage.
  • Season Summaries – One-command overview of entire season performance.
  • Closest Finishes Tracker – Finds top 10 closest real-time stage battles per week or season.
  • Custom Points System – Calculates seasonal points automatically.
  • Full Archived Access – Query any season/week in history.
  • Left & Right Leaderboards – Captures both panels from RallySimFans.hu.
  • Reconnect Watchdog – Alerts if bot fails to reconnect or gets stuck.

πŸ’¬ Commands

πŸ‘€ Driver Commands

!search [driver] [s#w#]        β†’ Driver's full results by stage (dropdown if blank)
!stats [driver]                β†’ Total events, avg pos, wins, podiums, car, points
!history [driver]             β†’ Week-by-week position and gap on general leaderboard
!trend [driver]               β†’ Performance trend across weeks (time, icons, podiums)
!progress [driver]            β†’ Stage-by-stage completion for current week

πŸ“ˆ Leaderboard & Season

!leaderboard [s#w#]           β†’ General leaderboard for a specific week
!leg1 to !leg6 [s#w#]         β†’ Stage-specific leaderboard for each leg
!points                       β†’ Full season standings
!seasonsummary [s# or now]   β†’ Recap of legs, stages, drivers, points
!mostwins                    β†’ Top 10 most stage wins
!compare driver1 vs driver2   β†’ Head-to-head breakdown
!closestfinishes [s# or s#w#] β†’ Top 10 closest real gaps (week or full season)

πŸ› οΈ Admin Commands

!sync                         β†’ Force sync from Google Sheets
!rescrape [s#w# or s#]        β†’ Re-scrape week or season
!recalpoints                  β†’ Recalculate points from DB
!dbcheck                      β†’ Check DB health and row counts
!restart                      β†’ Restart the bot
!shutdown                     β†’ Shut the bot down

🎯 Fun / Utility

!cmd                          β†’ Lists all commands
!info                         β†’ Rally info (name, password, URL)
!skillissue                   β†’ Motivational message for last-place driver

πŸ’‘ You can run !search, !stats, !history, !trend, or !progress with no driver name to open dropdown selection.


βš™οΈ How It Works

  • Scraping: Uses requests + BeautifulSoup to pull data from rallysimfans.hu.
  • Database: MySQL schema logs results, stats, and point data.
  • Bot Framework: Built on discord.py with async task loops and UI elements.
  • Environment Driven: URLs, tokens, and sync data pulled from .env and Google Sheets.
  • Offline-Resilient: DB ops retry automatically if MySQL goes down.
  • Leader Watch: Background loops check for leaderboard changes and notify.
  • Reconnect Watchdog: Bot notifies if stuck in a reconnect loop.

πŸ—“οΈ Installation Guide

πŸ”§ Requirements:

  • Python 3.10+
  • MySQL 8.0+ running and reachable
  • Discord bot token
  • Google service account JSON file

πŸ› οΈ Setup Steps

  1. Clone this repo:
git clone https://github.com/Snaze878/RBR_Bot_MySQL.git
cd RBR_Bot_MySQL
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up your .env file with:
DISCORD_TOKEN=...
DB_HOST=...
DB_USER=...
DB_PASS=...
DB_NAME=...
GOOGLE_SHEET_KEY=...
  1. Place your google_creds.json in the root folder.
  2. Run the bot:
Start_Bot.cmd

πŸ“ File Structure

RBR_Bot_MySQL/
β”œβ”€β”€ Start_Bot.cmd              # Launch the bot on Windows
β”œβ”€β”€ RBR_Bot.py                 # Core bot logic
β”œβ”€β”€ .env                       # Secrets and config
β”œβ”€β”€ google_creds.json          # Google Sheets service account
β”œβ”€β”€ requirements.txt           # Python dependencies
β”œβ”€β”€ logs/                      # Output logs (daily rotation)

πŸ“Έ Example Output

Click to expand

Leaderboard Points Search Leg Stats


🀝 Contribute & Support

PRs and suggestions welcome! Join the dev/support community:

🌐 Discord Support Server


πŸ“œ License

This project is licensed under the GNU GPL v3.

About

This bot is designed to scrape online leaderboards and provide real-time updates by database on rally standings from https://rallysimfans.hu/.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors