Code Monkey home page Code Monkey logo

fcomserver's People

Contributors

gauravatcs avatar norrisng avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fcomserver's Issues

Don't forward messages from user-defined list of callsigns

Allow users to specify a blacklist for forwarded messages.

That is, a user should be able to specify callsigns from which they don't want messages to be forwarded.

This blacklist of callsigns should be defined by the user via the Discord bot.

Auto-capitalize user's callsign

When storing user-entered callsigns (i.e. the first thing that gets entered when the client is opened), auto-capitalize them before saving them to the database.

Ultimately, it doesn't really matter that much, as its only use is to serve as a "confirmation" for the user. It merely provides a way for a user to make sure that their verification code hasn't been used by someone else (via the status bot command).

That being said, it does look nicer.

Bot partially crashes when a non-DM message is received

Whenever a on_message(message) event is triggered, and the message object provided doesn't belong to a DMChannel (e.g. belonging to a TextChannel instead), the forward_messages() loop crashes. Incoming messages (from the API) will continue to pile up in the DB queue. However, bot commands (i.e. register/status/remove) will continue to work.

Restarting the bot will temporarily solve the issue until a non-DMChannel message is once again presented to the bot.

Memory leak

There appears to be a memory leak with the bot, as restarting it will release some RAM. The cause of the memory leak is unknown.

The bot was manually restarted after 14 days (Oct 20 - Nov 2), releasing 91.1 MB of memory. Of note, however, is that CTP happened during the beginning of this window, and that FCOM has seen the highest level of activity this event. However, it's still far from what would be expected for widespread use.

Bot does not acknowledge remove request

When a registered user (confirmed or otherwise) sends remove to the bot, their registration entry is removed, but the bot does not reply with a message acknowledging removal (as is expected).

However, this does not occur if the user is not registered.

IVAO/VATSIM integration

Download/parse data from the data feeds for IVAO and VATSIM, allowing for richer functionality:

In the case of IVAO, all data will have to be downloaded/unzipped/parsed, due to the lack of granularity in Whazzup.

Incorrect parsing of frequency for messages sent over frequency

Text messages sent over frequency are not parsed into a friendly format as intended (e.g. "122.800 MHz"). Instead, they're simply displayed as the original 6-digit number encoded by the FSD server (e.g. "122800").

It appears that VATSIM encodes frequencies differently compared to IVAO. The existing code assumes that VATSIM uses the same format as IVAO (see below):
* VATSIM: xxxyyy for xxx.yyy MHz
* IVAO: @xxyyy for 1xx.yyy MHz

Warn user if using outdated client

Warn the user if they are using an outdated client version.

This information is contained inside the user agent string of client requests, starting with version 0.8.0 (FcomClient/0.8.0). All builds prior to this will instead provide the default RestSharp user agent (RestSharp/106.3.1.0)

Generate alphanumeric-only verification codes

Currently, verification codes can contain other characters, as long as they're URL-safe.

Instead, generate verification codes that only have alphanumeric characters. This makes it easier to simply double-click to highlight the entire code in Discord.

Credit: bantha121

Migrate to MariaDB

SQLite is used currently. Migrating to MariaDB will allow for concurrent access.

The following things will need to be changed to reflect this:

  • Schema (e.g. changing to bool, varchar)
  • Database connections in db_manager.py

Also, stop using autoincrement, and use message timestamps for ordering instead. There may be a need to write a DB trigger for insert time, so that clients can't manipulate message queue priority.

Quick reference: https://mariadb.com/resources/blog/how-connect-python-programs-mariadb

Bot fails to auto-recover after a Discord server outage

After the Discord outage on 2019-01-12 at 1050z, the bot failed to forward any messages, even after Discord was back up and running.

In this case, the server threw a HTTP 500 error:

Task exception was never retrieved
future: <Task finished coro=<forward_messages() done, defined at .../FcomServer/bot/discord_bot.py:17> exception=HTTPException('INTERNAL SERVER ERROR (status code: 500): 500: Internal Server Error',)>
Traceback (most recent call last):
  File ".../FcomServer/bot/discord_bot.py", line 44, in forward_messages
    await dm_channel.send(dm_contents)
  File ".../FcomServer/venv/lib/python3.6/site-packages/discord/abc.py", line 764, in send
    data = yield from state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce)
  File ".../FcomServer/venv/lib/python3.6/site-packages/discord/http.py", line 221, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: INTERNAL SERVER ERROR (status code: 500): 500: Internal Server Error

Retry API events if database is locked

Currently, registration and message forwarding events will fail if the database is locked.

Instead, it should re-attempt the database operation some number of times. Probably not a good idea to reattempt an infinite number of times, so that the client isn't stuck waiting.

Send message to user on confirmation

When a registration is confirmed by the client, send a message to the user over Discord.

This can be implemented by having the API additionally insert a message into the messages table whenever the registration endpoint is called.

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.