Git Product home page Git Product logo

rleb's Introduction

Python Tests codecov

Legal Disclaimer

The author(s) disclaim copyright to this source code.
In place of a legal notice, here is a blessing:

	May you use your opportunities for good and not ill.
	May you find forgiveness for yourself and for others.
	May you share freely, never taking more than you give.

r/RocketLeagueEsports Bot (RLEB)

This is RLEB - a bot that is developed and maintained by the moderators of https://www.reddit.com/r/RocketLeagueEsports.

RLEB has many features including

  • Handling user flairs
  • Tools to build reddit threads
  • Tools to organize moderator tasks
  • Reddit <---> Discord bridges
  • And many other small tools that mods use to improve their job

Running RLEB:

  1. pip install -r requirements.txt
  2. python rleb_core.py

Note that you will need to create an rleb_secrets.py file if running RLEB locally. This file contains info about API keys, usernames, etc. Check out the sample secrets to learn more. You can also deploy with these secrets key-value pairs as OS ENV variables.

If using liqui tools, you should also run Diesel @ 127.0.0.1:8080. Diesel is a fast media wiki parser that turns media wiki pages into reddit markdown. It's written and Go and is impemented as an http server that RLEB can talk to. RLEB can also parse media wiki, but it is over 10x slower than Diesel.

Apple lol

Mac users (especially on M1 chipset) may need to set certain flags to be able to install everything from requirements.txt.

# Clone rleb into a fresh directory

> brew install postgresql

# Open new terminal window

> export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
> export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib -L${HOME}/.pyenv/versions/3.8.10/lib"
> python3 -m venv env
> source env/bin/activate
> pip3 install -r requirements.txt
> pip3 install aiohttp==3.7.4
> pip3 install -U discord.py

# Go to MacintoshHD -> Applications -> Python3.x Folder
# Double click on the "Install Certificates.command".

rleb's People

Contributors

j-wass avatar alexckrueger avatar trevorcrupi avatar dependabot[bot] avatar

Stargazers

Cloei avatar Juho Leinonen avatar

Watchers

 avatar  avatar

rleb's Issues

add tests for !mvp

just basic things, with mocked google forms and liqui responses, ideally

migrate away from pastebin

pastebin limits to 20 posts a day

If the bot grows, it may be used dozens of times a day, especially during live events.

Find an unlimited paste provider.

Create more user-friendly calendar for users

General idea being to run two calendars simultaneously.
One dev calendar and one user calendar.
The dev calendar being the one we update and creates the weekly schedule and all the bot related things.
The user calendar which is the one users subscribe too but is parsed and updated by the dev calendar.
The fundamentals of which are that when the dev calendar is updated we sanitize the markdown so the users don't see all the funky brackets. Would require synchronization between dev calendar and user calendar.

Example

[**RLCS 21/22: OCE Regional 1 - Day 2**](https://liquipedia.net/rocketleague/Rocket_League_Championship_Series/2021-22/Winter/Oceania/1) 

becomes

RLCS 21/22: OCE Regional 1 - Day 2

With all other relevant properties such as timings and location (twitch.tv) in the same place and/or description.

Requirements

  • Create new calendar (dev) so current users don't have to migrate to a new calendar.
  • Give mods access to dev calendar to update from now on.
    • They can continue to update it as usual
    • Repoint all bot code to use the dev calendar
  • dev calendar sanitizes markdown and updates events in user calendar.
  • Never update the user calendar directly, but only through the dev calendar. (Would cause them to be out of sync)

testing mode

When running in local mode, bot should add "test" before each !command.

It should also hook into r/RLCSNewsTest instead of r/RocketLeagueEsports.

Less important ideas:
Prepend logs in this mode with "test" or debug or something.

!bracket

a !bracket <liquipedia-url> command that pulls elimination brackets from liquipedia into basic reddit markdown.

starter js code:

document.querySelectorAll(".brkts-round-center").forEach((e) => {
  timer = e.querySelector(".timer-object")
  if (timer == null){
    return;
  }
  is_finished = timer.getAttribute("data-finished")
  console.log(timer.innerText + " (" + is_finished + ")")
  e.querySelectorAll(".brkts-opponent-entry").forEach((b) => {
    console.log("team: " +b.querySelector(".name").innerText) 
      console.log("score: " + b.querySelector(".brkts-opponent-score-inner").innerText)
  });
  console.log("----------")
});

!tasks, which should list your tasks for the next week from #weekly-schedule

!tasks -> returns tasks for me
!tasks [player-name] -> returns tasks for player-name

Would need some kind of pointer to the correct sheet. Can either do:

  1. Use the last link posted in #weekly-schedule. (Requires the weekly admin to post the link).
  2. Contain a hardcoded permalink to the sheet, and use the newest sheet. (May mess up when playing with the sheet).

Will probably need to use the Google Sheets API unless we want to crawl csv.

Change !bracket round names

Reddit tables are too long - shorten these names

Get rid of "bracket"
Change "Semi-finals" to be "semis"
Change "Quarter-finals" to be "quarters"
etc...

improve task alerts

  • send warning dms to users
  • db-remember misformatted posts
  • add a message in #schedule_chat when a post has been scheduled (and db-remember it)

rewrite discord command if-else chain to a declarative syntax

registerCommand(BracketCommand)

BracketCommand = Command(name="Bracket", staff_only=True, handler=bracket_command_handler)
def bracket_command_handler(self. command_tokens: List[str]):
   # now use some fancy node-based tree of command tokens to answer

!streams

js prototyping code

broadcast_tables = document.querySelectorAll("h4 ~ div > table.sortable.wikitable.jquery-tablesorter")
markdown = "|||||\n|:-|:-|:-|:-|"
pairs = []
for (table of broadcast_tables){
  rows = table.querySelectorAll('tbody')[0].querySelectorAll("tr")
  teams = rows[0].querySelectorAll("td")
  streams = rows[1].querySelectorAll("td")
  
  new_row = ""
  for (i = 0; i < teams.length; i++){
    teamname = teams[i].querySelectorAll("a")[0].title
    stream_name = "https://liquipedia.net/rocketleague/Rocket_League_Championship_Series/2021-22/Spring/Europe/1"
    if (i < streams.length){
      stream_name = streams[i].querySelectorAll("a")[0].title
      if (stream_name.includes("Special:Stream/twitch/")){
          split =  stream_name.split("/")
          stream_name = "https://www.twitch.tv/" + split[split.length-1]
      }
    }
    pairs.push([teamname, stream_name])
    
  }
  // create markdown, 4 teams per row
  
  while (pairs.length > 0){
      new_row = ""
      four_teams = pairs.slice(0,4)
      pairs = pairs.slice(4)
    
      console.log(four_teams)
      for (team of four_teams){
        new_row +=  `|[${team[0]}](${team[1]})`
      }        
      markdown += "\n" + new_row
  }
}
console.log(markdown)

standardize discord responses

handlers often have the power to message a channel

only discord_bridge should be messaging the channel, and handler should just be a call and response

add !remindme

perhaps "!remindme [timeframe] [message to remind]" ?

ignore emoji requests in !triflairs

Users can do !triflairs add :happy: to add the :happy: flair to the triflair system

But if that user has nitro + emojis enabled, then the bot sees !triflairs add ๐Ÿ˜€ (note that :happy: has been replaced with the emoji). This causes the emoji code to be stored, and not the literal string ":happy:"

  1. Detect whether a !triflairs user has accidentally send an emoji.
  2. Reject the input, and tell the user to disabled auto emoticon conversion while using triflairs: Settings -> Text & Images -> Automatically convert emoticons in your messages to emoji.
  3. Add tests to ensure it works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.