Giter Site home page Giter Site logo

vostpt / bot Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 4.0 66.9 MB

Source code of VOSTPTia - @vostpt's official bot

Home Page: https://vostpt.github.io/bot/

License: MIT License

JavaScript 99.81% Shell 0.19%
bot discord-bot javascript mastodon-bot nodejs pleroma-bot portugal telegram-bot twitter-bot

bot's People

Contributors

claudiovarandas avatar dependabot[bot] avatar duarte23 avatar gadelhas avatar j0n4s13 avatar jorgemiguelgomes avatar marcoacmaia avatar micaelmcarvalho avatar miguelantoniosantos avatar miguelcarreiro avatar msramalho avatar oldmetalmind avatar tiagojpdias avatar tomahock avatar vostportugal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bot's Issues

IPMA Idle Time

If the warning is sent out to twitter between 02:00h and 6:00h:

  • Bot should quote-tweet original tweet with the text " ℹ️ Enquanto dormias ℹ️ "

[Bug] Fix hour

Bot is returning the real date+hour time plus one hour.

[Bug] !rcm command

Command needs a fix to only send one message to the designated channel. At the moment it's sending one per minute for one hour.

[Feat] Monitor Google Sheet to notify Discord and Tweet

Context

With the COVID-19 pandemic, the amount of data that has to be consumed, validated, and tweeted is immense.
FAQ are a great way to gather information in one place, but we still need to make manual tweets to announce new insertions.

Solution

Develop a feature on VOSTia that monitors a Google Sheet's responses and when a new response is inserted:

  • Alerts a certain channel on Discord
  • Tweets the question on twitter automatically with a general link (to be provided) and with an image attached (to be provided)

[FEAT] Do a checksum on DGS COVID-19 reports

Today we saw the first updates on DGS reports. To make clearer the difference between reports, it would be nice to store a checksum of the PDF in the database. Then, when the bot messages the report to Discord, it can include said checksum 😄

It might seem overkill, but it's probably a good pattern to keep for future bot jobs/commands.

WDYT?

[Bug] miscellanous.js

const replies = [
  'Provavelmente a melhor VOST do mundo',
  ':eyes:',
  ':heart:',
  'Sabias que a VOSTPT primeiro se chamou CONAC-TW no Twitter?',
];

module.exports = {
  name: 'Miscellaneous',
  description: 'Miscellaneous things',
  async execute(message) {
    const messageContent = message.content.toLowerCase();


    if (messageContent.includes('vostpt')) {
      const replytext = Math.floor(Math.random() * replies.length + 0);

      try {
        message.reply(replies[replytext]);
      } catch (e) {
        //
      }

      return;

Bot is returning 3 messages, not one
Screenshot 2019-04-19 at 01 05 37

[Feat] Discord Channels

The bot should have the following behaviour:

  • Listen for keywords /triggersonly on channel ID: 501329363166560263 (Our public channel) - This is item is high priority or someone will kill the bot soon (looking at you @quetzyg)

  • Bot will reply to triggers only on aforementioned channel ID.

[Feat] Weather Warnings Twitter Interaction

Introduction

Weather warnings are fundamental and are the base of any activation for civil protection services, as well as VOST, so they should be broadcasted as fast as they are issued on our social networks.

Features

The flow, that is already implemented but with some errors (mostly formatting), is this:
IPMA Warning -> Bot -> Twitter

Examples

Aviso Açores https://twitter.com/VOSTPT/status/1109010606940700677

Aviso Madeira https://twitter.com/VOSTPT/status/1077190310474719232

Thread de Avisos Continente durante o Furacão Leslie https://twitter.com/VOSTPT/status/1051096510203613185

Request

To automatically generate individual tweets or threads when a warning is issued by IPMA, maintaining VOST Portugal's current layout (emojis and pictures/gifs).

Also important: Include in those tweets a random message from a predefined list.
Example: https://twitter.com/VOSTPT/status/1110881712542756864 ( #EstáFlatParaOGareth Boa onda é não enfrentar as ondas)

[Feat] Bot should send commands via private message

In order to avoid cluttering channels with information, when a user sends the "?commands" command, the bot should:

  • reply to the user that the command's list was sent via private message
  • send commands' list via private message

[BUG] Message formatting

Bot is returning a string with omissions and formatting errors:
Example:
#IFGrândola,Grandola#troia

Should be
#IFGrândola, #Grândola, #Troia

[Feat] Command !sns24 alerts

  1. Fetch only latest warnings or return message "Sem avisos recentes"
  2. Broadcast automatically to Discord channel 502836523440537620 latest warning
  3. Send latest warnings to Twitter account
  4. Command should include Icarus warning

[Feat] Codebase tests

Implement tests to cover the code quality and provide extra confidence when refactoring.

[Feat] Create "activation time"

When VOST it's on activation the bot says how many hours since the start of the activation.
Only the founders can !startactivation and !stopactivation.
When someone type !ativacao bot display how many time activation have started in hours.

  • Only Founders can send to the bot a command, for example,

    • !vostia start activation <activation_name>
      As soon as the command is sent, the bot should return a message to the public channel #vost-portugal-publico with the message:

    @everyone entramos agora em ativação devido a <activation_name>

    • !vostia end activation <activation_name>
      As soon as the command is sent, the bot should return a message to the public channel #vost-portugal-publico with the message:

    @everyone acabou a ativação devido a <activation_name>. Obrigado!

    The bot should then return the total of hours since the start of the activation to the same public channel

  • All users should be able to check, and get the information via PM, of current activation hours with a command, for example:

    • !vostia stats activation <activation name>

Commands and Structure

These commands should be in a separate folder called "fires", with a file for each command:
!all
!all [human|ground|air] [numero_filtrar]
!all links
!all important
!op id [numero_id]
!op if [#IFConcelho]
!op status [Despacho|Curso|Resolução|Conclusão|Vigilância]
!op distrito [nome_distrito]
!rmc


These commands should be in a separate folder called "weather", with a file for each command:
!weather
!weather tomorrow


Interaction with Twitter should be made via a separate file.

Break functions apart

At this time the bot works in a fantastic way but:

  • We have an unique code file for all the functions, resulting in having actionable data and just for fun content in the same file.

Proposal

  • Clean the code
  • Validate the code
  • Comment the code (this is important so everyone knows what is going on with the code)
  • Separate the code into multiple files, one for each use case.

[FEAT] Earthquakes

VOSTia is not:

  • Not posting, in real time, incidents to #sismos_tsunamis channel of earthquakes => 2.5
  • Not posting to Twitter

[Feat] Remind DGS on Twitter of missing daily reports on the website

Issue
Since 17.08.2020, the day that DGS launched a new report model, several reports were deleted from the website.
Reports 1 to 11, and report 38 return a "Not Found" message.

DGS has been formally informed that the reports are missing but has done nothing to about it.

Solution (?)

The requested feature is not a solution in itself, but a public awareness campaign for this problem.

Every day, at random hours, VOSTPTia shall check if the missing bulletins are still missing on the official repository for those . If they are still missing send a tweet mentioning DGS. The tweet content should be randomize from a given set of phrases to be written and stored, preferably, in a text file to be updated as needed be.

[Feat] Change IPMA warnings tweet structure and photos

Change tweet structure to this:
#<warning_level> devido a #<warning_type> entre as <start_HH:mm> de <relative_start_date> <start_DDMMMYY> e as <end_HH:mm> de <relative_end_date> <end_DDMMMYY> para os distritos de <warning_issued_districts>
Example:
ℹ️⚠️☀🌡 #AvisoAmarelo devido a #TempoQuente entre as 00:00 de hoje 15AGO19 e as 20:00 de amanhã 16AGO19 para os distritos de #Beja, #CasteloBranco, #Évora e #Portalegre ☀🌡⚠️ℹ️

We need also to change image tweet to the newest warning images.

[Feat] Acrónimos

  • Permitir adicionar acrónimo se não existir
    O acrónimo não consta na base de dados! Queres adicionar (s/n)?
    Se sim: Então diz-me o que significa [Acrónimo não encontrado]
    Recebe
    Retorna: Muito obrigado!

  • Integração com o Twitter
    Permitir a qualquer utilizador perguntar "O que significa [Acrónimo]?"
    Se constar na base de dados devolve "[Acrónimo] significa "descrição"
    Se não constar da base de dados devolve "Não sabemos o que isso significa mas vamos tratar de saber." (Envia mensagem para o Discord com "@here alguém no Twitter quer saber o que quer dizer [Acrónimo])

Estou ciente que isto pode alimentar trolls mas podemos criar uma blacklist de palavras.

[Chore] Swap API endpoints to the new API

We need to change the endpoints which the bot is getting info from.

It's not plug&play since the response structure is different since its compliant with JSON API specification.

Add sqlite database for IPMA warnings

Since old API will be deprecated, it's necessary to change the way bot get and save IPMA warnings.
For that, was decided that the best way to do it is to implement sqlite and sequelize.

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.