Skip to content

Commit

Permalink
Refactor/add typescript (#11)
Browse files Browse the repository at this point in the history
* Added .env example

* refactor(add-typescript): Migrated from vanilla JS to TypeScript

* refactor(add-typescript): Updated README
  • Loading branch information
jpmoura authored Nov 29, 2020
1 parent 158dbbc commit ba83892
Show file tree
Hide file tree
Showing 46 changed files with 564 additions and 453 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BOT_TOKEN=myBotToken
TWITTER_CONSUMER_KEY=myTwitterConsumerKey
TWITTER_CONSUMER_SECRET=myTwitterConsumerSecret
TWITTER_ACCOUNTS=NFLResearch,RapSheet,AdamSchefter,SomeOtherCoolAccountName
FANTASY_LEAGUE_ID=myFantasyLeagueId
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
lib
dist
18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"jest"
],
"extends": [
"airbnb-typescript/base",
"plugin:jest/all"
],
"parserOptions": {
"project": "tsconfig.json"
},
"rules": {
"class-methods-use-this": 0
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ typings/
# SonarScanner properties
/sonar-project.properties
.vscode/launch.json

/dist
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript", "typescript", "typescriptreact"],
"eslint.alwaysShowStatus": true,
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ My motto to create this bot came from my frustration to find a reliable service

## Requirements

The only requirement it is at least a Node version that bundles the ```promisify``` utility (*i.e.* Node 8)
The only requirement it is at least a Node version that bundles the ```promisify``` utility (*i.e.* Node 12)

## Using the bot

Expand All @@ -24,7 +24,7 @@ In order to use this bot you need to create a .ENV file with two specific keys:

You will need to apply for a key in [Twitter](https://developer.twitter.com/en/apply-for-access.html). After set this .ENV file with these five keys, just run the command ```npm install && npm start```.

This bot was built on top of NodeJS v8.9.4.
This bot was built on top of NodeJS v12.

## Know Issues

Expand All @@ -38,10 +38,10 @@ If you plan to serve this bot to different users and not just for yourself you g

* Automatized tests that covers at least 80%;
* Persist the chat ids;
* More elegant message about Fantasy League transactions;
* ~~More elegant message about Fantasy League transactions;~~
* Allow to add more than one fantasy league to update about it.
* Aggregate posts from [NFL @ Instagram](https://www.instagram.com/nfl/);
* Add Web User Interface to set the tokens and leagues ids;
* Dockerfile aiming a simple way to deploy the bot.
* ~~Aggregate tweets from [@NFLResearch](https://twitter.com/NFLResearch) for real time statistics about the games~~
* ~~Build a more elegant message, possibly using MarkDown instead using images with caption.~~
* ~~Build a more elegant message, possibly using MarkDown instead using images with caption.~~
7 changes: 0 additions & 7 deletions config/bot.js

This file was deleted.

9 changes: 0 additions & 9 deletions config/fantasy.js

This file was deleted.

9 changes: 0 additions & 9 deletions config/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions config/twitter.js

This file was deleted.

30 changes: 0 additions & 30 deletions consumers/fantasy/index.js

This file was deleted.

54 changes: 0 additions & 54 deletions consumers/nfl/index.js

This file was deleted.

57 changes: 0 additions & 57 deletions consumers/twitter/index.js

This file was deleted.

51 changes: 0 additions & 51 deletions index.js

This file was deleted.

11 changes: 11 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Telegram from 'telegraf/telegram';
import Telegraf from 'telegraf';
import { TelegrafContext } from 'telegraf/typings/context';
import BotManager from './src/application/BotManager';
import Configuration from './src/config/Configuration';

const bot: Telegraf<TelegrafContext> = new Telegraf(Configuration.bot.token);
const mailman = new Telegram(Configuration.bot.token);
const botManager: BotManager = new BotManager(bot, mailman);

botManager.start();
Loading

0 comments on commit ba83892

Please sign in to comment.