Giter VIP home page Giter VIP logo

bot's Introduction

Logo VOSTPTia

VOSTPTia

VOSTPT bot

Build status Coverage Status

Installation

Before anything else, install the dependencies:

yarn install

or for those who prefer npm:

npm install

Configuration

After installing the dependencies, it's time for a quick configuration.

Create a .env file in the project root.

cp .env.example .env

Create the database directory and execute Sequelize migrations:

mkdir ./data
#ENVIRONMENT: development | test | production
npx sequelize-cli db:migrate --env ENVIRONMENT

Add and replace values where needed:

#
# Discord bot token
#
BOT_TOKEN=

#
# Cooldown interval in seconds
#
COOLDOWN=30

#
# The channels to where messages should be sent
#
MAIN_CHANNEL_ID=
EARTHQUAKES_CHANNEL_ID=
FIRES_CHANNEL_ID=
WARNINGS_CHANNEL_ID=
WARNINGS_AZ_CHANNEL_ID=
WARNINGS_MD_CHANNEL_ID=
FUEL_CHANNEL_ID=
TRIGGERS_CHANNEL_ID=
MGMT_CHANNEL_ID=
VOLUNTEERS_CHANNEL_ID=
TWFEED_CHANNEL_ID=
FBFEED_CHANNEL_ID=
DGSCORONA_CHANNEL_ID=
JOURNAL_CHANNEL_ID=

#
# Discord commands user permission list
#

CORONAUPDATEROLES=
CORONAUPDATEUSERS=

RALLYUPDATEROLES=
RALLYUPDATEUSERS=

#
# Twitter configurations (Main account)
#
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_ACCESS_TOKEN_KEY=
TWITTER_ACCESS_TOKEN_SECRET=

#
# Twitter configurations (Azores account)
#
TWITTER_AZ_CONSUMER_KEY=
TWITTER_AZ_CONSUMER_SECRET=
TWITTER_AZ_ACCESS_TOKEN_KEY=
TWITTER_AZ_ACCESS_TOKEN_SECRET=

#
# Twitter configurations (Europe account)
#
TWITTER_EU_CONSUMER_KEY=
TWITTER_EU_CONSUMER_SECRET=
TWITTER_EU_ACCESS_TOKEN_KEY=
TWITTER_EU_ACCESS_TOKEN_SECRET=

#
# Twitter configurations (Journal account)
#
TWITTER_DRE_CONSUMER_KEY=
TWITTER_DRE_CONSUMER_SECRET=
TWITTER_DRE_ACCESS_TOKEN_KEY=
TWITTER_DRE_ACCESS_TOKEN_SECRET=

#
# Twitter configurations (Rally account)
#
TWITTER_RALLY_CONSUMER_KEY=
TWITTER_RALLY_CONSUMER_SECRET=
TWITTER_RALLY_ACCESS_TOKEN_KEY=
TWITTER_RALLY_ACCESS_TOKEN_SECRET=

#
# Facebook configurations
# instructions to get keys: https://gist.github.com/msramalho/4fc4bbc2f7ca58e0f6dc4d6de6215dc0
#

# Main account
FACEBOOK_TOKEN_VOSTPT=

#
# FTP configuration
#

FTPSERVER=
FTPUSER=
FTPPASSWORD=

#
# DGS resume spreadsheet
#

DGSRESUMESID=
DGSRESUMESGID=

# Node environment (for Sequelize)
# test/development/production

NODE_ENV=

#
# Beta mode (run only beta commands, disable all other functions)
# When disabled ('false' or empty), run all but beta commands
#
BETA_MODE=


#
# Telegram
#
TELEGRAM_API_KEY=
TELEGRAM_CHAT_ID=

TELEGRAM_RALLY_API_KEY=
TELEGRAM_RALLY_CHAT_ID=

#
# Firebase warnings key
#

WARNINGAPPKEY=

#
# Mastodon/Pleroma keys
#

MASTODON_ACCESS_TOKEN=
PTDRE_PLEROMA_ACCESS_TOKEN=

#
# PT Rally csv file location
#
RALLYFILEPATH=

You will also need a data/auth/vostpt-bot.json config (can be test version).

Running

If you went through the previous steps successfully, you should now be able to run VOSTPT Discord bot with the following command:

npm start

Tip: use the BETA_MODE env variable to toggle which function in src/jobs/index.json is executed startProd (BETA_MODE=false) for production and startBeta (BETA_MODE=true).

You should see an output similar to this:

READY :: Bot started @ 2019-4-14 21:27:00

That's it!

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

[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>

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] 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)

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.

[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.

[Bug] Fix hour

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

[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

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.

[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] 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.

[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

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 ℹ️ "

[Feat] Codebase tests

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

[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)

[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.

[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

[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?

[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.

[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] Earthquakes

VOSTia is not:

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

[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.

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.