Giter Club home page Giter Club logo

sunbot's People

Contributors

clement-pages avatar deepsource-autofix[bot] avatar deepsource-io[bot] avatar deepsourcebot avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

sunbot's Issues

Reimplement `disconnect` command

Task description

This command was implemented in the first version of the bot in order to simulate a logout of the bot from discord. The purpose of this task is to re-implement that command as a slash command. This command can only be used by bot developers.

Validation criteria

  • : Implement disconnect slash command

Implement a Meteo France weather alert handler

Task description

Through its public data platform, Meteo France provides a set of API that can be used by applications. One of these API provide data for weather alert. Thus, the purpose of this issue is to create an handler to manage the request an response retrieval between this API and the SunBot. This handler should inherit the general handler class (#90 ).

Validation criteria

  • : Implement a class that handles access to the Meteo France weather alert API.

Improve the "pluie" slash command

Task description

The purpose of this task is to upgrade the pluie slash command

Validation criteria

  • Convert this command to a slash command
  • Replace the current embed response with an image or a graph
  • Test the improvement on Discord

Transform the `SunController` class into a discord cog

Task description

The SunController can be seen as a collection of commands and event listeners. This corresponds to the definition of a commands.Cog in the discord API. Thus, one improvement for the SunController might be to make it inherit from the commands.Cog class, as indicated in the documentation. Do that would allow to reduce amount of code in the main script.

Validation criteria

  • : Inherit SunController class from commands.Cog and add needed decorator as described in the documentation
  • : Update the code in the main.py python script to take into account SunController modification

Add PM functionnality to send daily weather to users

Task description

For now, the bot is only able to send daily weather message on Discord server, for any location known by the Visual Crossing API. But the bot cannot send this type of message in private to a specific user. Up to know, the development of this feature was blocked by the bot architecture that was based on threading.Threadwhich are not compatible with asynchronous tasks used by discord API. But with commit 80dbd88, bot relies from now on asyncio task. This should allow the bot to send private message.

Validation criteria

  • #61
  • #62
  • Test on discord for different locations

reduce the amount of memory required by the subscribers structure in `weather_event`

Task description

In order to send daily weather to each users and guilds that subscribe to one or more locations, the locations' subscriberd dict keeps in memory all the necessary discord.Interaction objects. This makes it easier to send daily weather to each subscriber. But a discord.Interaction instance holds a lot of unneeded data which are not used in this case, and so wastes memory. It should be better to only keep in memory used elements of an Interaction instance, according to the subscriber type:

  • interaction.channel to send daily weather to a specific guild's channel
  • interaction.user to send daily weather in PM to a specified user
    All other data can be ignored. This will facilitate the save of the locations' subsrivers dict, mentioned in #65

Validation criteria

  • : Replace discord.Interaction by interaction.channel or interaction.user according to the subscriber type
  • : Test that nothing was broken

(PTC-W0011) Use `items()` to iterate over a dictionary

Description

The preferred way to iterate over the key-value pairs of a dictionary is to declare two variables in a for loop, and then call dictionary.items() (or dictionary.iteritems() for Python2), where dictionary is the name of your variable representing a dictionary.'

Occurrences

There is 1 occurrence of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/clement-pages/SunBot/issue/PTC-W0011/occurrences/

Hide bot token

Task description

The discord token for the bot is actually visible in the main program. This is a security issue.

Validation criteria

  • : Replace the line containing the visible token by a call to the corresponding environment variable
  • : Create a new token here and update the environment variable value on Fly.io

Create a discord API handler

Task description

Actually, discord API is directly accessed from multiple points in the source code. This could break the code if discord is updated, and makes it difficult to maintain. Thus, the aims of this task is to implement a module that will represent an interface betwwen the SunBot

Validation criteria

  • : A first attempt to implement a discord API handler was done previously, but this implementation is not up to date with the current architecture and should be deleted
  • : Implement a new module which handle sending to users and servers, handle an interaction or discord event... etc
  • : Update the source code to use the new module (namely in SunController, weather_event module

Save location subscribers list (servers and users) for daily weather

Task description

For now, structures which hold servers and users that have subscribed for a specific location to receive events from this location are not saved. So if the bot shuts down, data in these structure will be lost. The purpose of this task is to avoid this. One way is to do the same as for user and server data saving

Validation criteria

  • Implement saving method in WeatherEvent and DailyWeatherEventclasses

Improve the handling of weather API requests

Task description

For now, the weather API handler just generates a request to the API and returns the response as a dictionary, without any modification to the data. The handler just prevents the user with log messages when the request failed. The purpose of this task is to improve the management of the response with the aim to improve the robustness of the bot to modification in the structure of returned JSON response. This is also the opportunity to fix style issue and to improve the code.

Validation criteria

  • Create dictionary(ies) from response data to only keep needed data in a standard format for all Sunbot modules
  • Adapt programs that use the current API handler structure
  • Test the new structure(s)
  • #69

Implement a general class to handle all requests from the bot to any web API

Task description

For now, each API used by the bot is handled in a specific way according to the specification and the use of this API. Thus, when a new API has to be implemented in the bot's source code, developers need to redevelop the whole pipeline (make a request, send it to the API, wait for a response and handle this response). This is not very convenient, time wasting and make the maintainability more complicated. The purpose of this task is to avoid that by implementing a general (abstract) class which will manage all of the previously mentioned tasks. Each handler for a specific API will then be an instance of an inherited class.

Validation criterias

  • : implement method to handle a request to an API. This method has to adopt its behavior according to the status code of the response, use timeout watchdog, certificate management and so on...
  • : implement a method to retrieve value from specific key in a JSON reponse. Key research should be recursive in order to handle deep structure
  • : implement a method which return a formatted response (a dictionary for example) from arguments given by the caller that can then use this response to achieve its goals
  • : Implement all method that can be useful for above methods
    This list of methods is not exhaustive and might be updated

Handle send of daily weather for all timezones

Task description

Currently, hour events are hard coded in the program, namely for daily weather event. Thus, developer have to manually switch from winter to summer hour and inversely. This is not convenient and need to deploy a new version for the bot each time. A solution is to automatically handle this point in the code.

Validation criteria

  • : Find a way to automatically switch between summer and winter hours
  • : Handle all timezones for daily weather feature
  • : Implement this solution in the code
  • : Test and validate the implementation

Refactor code in `weather_event` module

Task description

Code for handling server and user subscription is pretty much identical. This generate uneeded complexity in WeatherEvent class and should be refactored to reduce this complexity and facilitate future updates

Validation criteria

  • refactor the code
  • check that nothing was broken

(PYL-W1641) Defining equality for a class without also defining hashability

Description

In order to conform to the object model, classes that define their own equality method should also define their own hash method, or be unhashable. If the hash method is not defined then the hash of the super class is used. This is unlikely to result in the expected behavior. …

Occurrences

There are 2 occurrences of this issue in the repository.

See all occurrences on DeepSource → app.deepsource.com/gh/clement-pages/SunBot/issue/PYL-W1641/occurrences/

Create weather alert handler

Task description

A new feature of the Sunrise version is to alert the user when a weather alert is triggered by Meteo France (the national weather service in France). In a first time, to do that, the bot will send a webhook message to all discord servers that have enabled these features. This webhook will contain information about the thrown weather alerts such as level and type alert. For now, this new feature will be only available to the Haute-Garonne department.

Validation criteria

  • Create a user account on Meteo France API service
  • Get a token in order to use Meteo France API
  • #90
  • #91
  • #92
  • Implement webhook message generation and handle its sending on discord when an alert is triggered

Useful links

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.