Coder Social home page Coder Social logo

2kai2kai2 / eu4img Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 62.13 MB

A Discord bot for the video game EU4 that creates in-channel post-game reports, organizes game reservations, etc.

License: GNU General Public License v3.0

Python 77.69% C++ 22.12% Dockerfile 0.05% Shell 0.12% Procfile 0.01%
games eu4 europa-universalis-4 europa-universalis-iv after-action-report eu4-multiplayer scheduler discord discord-bot discord-py

eu4img's Introduction

Deployment State Code Size Total Size License GPL-3.0 Vulnerabilities

The Cartographer

This bot is a must-have for Discord servers that play the video game Europa Universalis IV (EU4) by Paradox Interactive.

While primarily intended for multiplayer campaigns, The Cartographer fully supports all applicable features for singleplayer.

Features:

1) Beautiful Post-Game AAR Stats

Similar to the popular tool Skanderbeg, The Cartographer provides statistics and a map showing information about an uploaded game save file. However, The Cartographer is unique in that it posts an aesthetically fitting image containing this information directly into the Discord channel.

To get started, simply type /stats in the channel where you want the display to be posted. There is an optional skanderbeg option which, if enabled, will automatically upload to Skanderbeg and post the link alongside the in-channel stats display.

The Cartographer will send you a direct message with instructions on how to upload the file and optionally modify the list of players to be displayed.

Stats Example

Map shows player borders including subject states. And yes, I am the one playing the unnecessarily wealthy Russia that has seized London, Tehran, and Beijing. For the record, colonialism and imperalism are bad IRL.

2) Managing Multiplayer Campaign Reservations

Easy commands to set up a channel for reservations. Simply set up a fresh channel for reservations and type /reservations

  • Avoid duplicates picks and conflicts: It's first-come, first serve (with admin overrides, of course)!
  • Automatically inform users when they've selected a banned nation.
  • Automatically delete messages to the channel that could push the reservation list up.
  • An image showing the picked nations, making it easier to find one you want to play that's open.
  • Most importantly, keep everything organized!

Reservations


How can I add this to my Discord server?

While we do not currently have a link to add the bot publically available, but you can request a link on The Cartographer Official Discord Server

Discord Button

Running Your Own Bot Instance

If you would prefer to run your own instance of the bot, you can. (If you're not sure, feel free to join the Discord server with the above link and ask!)

Depending on your system or hosting service, you may have different ways of running the program. However, there are a few things that are important:

1. Environment Variables

Either in your environment variables or in the .env file, provide the following:

Environment Variable Description
DISCORD_TOKEN A Discord bot token from the Discord Developer Portal.
SKANDERBEG_TOKEN (optional) A Skanderbeg API token for automatic Skanderbeg uploads.
MONGODB_USERNAME Username to access a MongoDB cluster where the bot will store its data.
MONGODB_PASSWORD Password to access a MongoDB cluster where the bot will store its data.
MONGODB_CLUSTERURL Cluster URL to access a MongoDB cluster where the bot will store its data.

A template can be found in the file template.env; simply rename to .env and modify.

2. Install Dependencies

The recommended method for running the bot is in a Docker Container. A Dockerfile is provided which will load the necessary dependencies.

If you decide not to use Docker, you can still install dependencies manually:

pip install -r requirements.txt

3. Run

If you choose to run the bot in a Docker Container, the command to start is already setup in Dockerfile.

If you decide not to use Docker, the following are example commands for starting up the bot:

Linux:

python3 EU4Bot.py

Windows:

python EU4Bot.py

However, many hosting services or different platforms may have different methods for running Python 3.x programs.


Updates

Updated game data will be needed when a new EU4 version is released. I will do my best to this as soon as possible after new game updates are released, but private bot instances will need to update from the GitHub repo.

eu4img's People

Contributors

2kai2kai2 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eu4img's Issues

Increase map border drawing speed

While every other item in the process of drawing the stats image takes less than a second, deciding where to draw player nation borders can take upwards of a minute. Reducing this is the primary goal for stats image optimization.

Load save data on startup

Save data needs to be loaded on startup.
On_ready, copy all the still valid reserve channels into interactions

Stats: Political mapmode image is held indefinitely waiting for user response

The political mapmode image is held in memory indefinitely until the user completes player list modification for the stats interaction. This could be forever if the user never completes or cancels the interaction.
Solutions:

  • Get image after modification, resulting in no wait time
    • Solves
  • Get image URL from discord and load after modification
    • Solves
    • Could not work if file message is deleted, resulting in file deletion after 1-24 hours.

Ensure all Discord snowflakes are stored and processed as ints

  • Mentions should be stripped and parsed
    • slash commands with role arguments give a string containing the int, which can be easily cast with int()
  • Storage in objects and variables

Standardize acceptable other inputs:
int
Guild/User/Member/Channel (we just get the id)
Do we accept strings that can be directly cast?

Stats: Make .eu4 file reading faster

Need to reduce processing on each line to increase speed. The file is very large, meaning small differences per line can have a major effect.

Switch Reserves to MongoDB

Controlled channels own a Reserve (or ASIReserve) object that is essentially a wrapper for a bunch of database calls, only keeping the channel ID that identifies all relevant data.
On MongoDB, all the data for reservations is stored in the conveniently-named "reservations" database. It has one collection called "index" that contains a document for each Reserve or ASI Reserve channel with data for each. There is then another collection for each of these, with a name consisting of a string of its channel ID (all digits) that contains a document for each player that has a reservation. Both the index and pick collection are identified by channel ID.

We could implement some sort of local caching of data eventually.

Readme Link to Discord Doesn't Work

Hi,

Not sure if you're still working on this project, but I was going to give it a try, but it looks like the link to ask for a bot link is broken. Intentional? If not, would love to see if I can get this to work for my savegame!

Switch Guild data to MongoDB

Unlike with reserves, this will not revolve around objects. Each function will simply have a parameter to specify guild. However, similarly to reserves, data will be stored on the database unless some local caching is implemented.

  • Default bans
  • Announcements (Implementation Pending)
  • Admin rank

Potential items:

  • Time zone
  • Default ASI-type teams
  • Server management
  • Player attendance checking

Errors if a guild doesn't have the specified rank

2019-12-16T03:32:59.893019+00:00 app[worker.1]: Ignoring exception in on_message
2019-12-16T03:33:00.002903+00:00 app[worker.1]: Traceback (most recent call last):
2019-12-16T03:33:00.005012+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/client.py", line 270, in _run_event
2019-12-16T03:33:00.005016+00:00 app[worker.1]: await coro(*args, **kwargs)
2019-12-16T03:33:00.005023+00:00 app[worker.1]: File "EU4Bot.py", line 944, in on_message
2019-12-16T03:33:00.005025+00:00 app[worker.1]: elif (text.upper() == prefix + "NEW") and checkResAdmin(message.guild, message.author):
2019-12-16T03:33:00.005027+00:00 app[worker.1]: File "EU4Bot.py", line 97, in checkResAdmin
2019-12-16T03:33:00.005030+00:00 app[worker.1]: return getRoleFromStr(s, os.getenv("MIN_ADMIN")) <= u.top_role
2019-12-16T03:33:00.005098+00:00 app[worker.1]: TypeError: '<=' not supported between instances of 'NoneType' and 'Role'

/help in controlled channels

/help should replace HELP in controlled channels. The context should be determined and the appropriate help message for the channel should be displayed.

Plan data structures and flow

-Guilds
-Reserves (different types)
-Be future-proofed to be able to save other kinds of controlled channels?

Determine how much of the data should be stored in memory/cached and for how long

  • Lookup performance
  • Memory usage
  • Sharding (is it irrelevant if each guild only has one shard?)

Customization for shown data

Could be either:
a. Settings file
b. Enter order in program (would need to be implemented without being too much work for users)

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.