-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(core): add typescript to api endpoints and utils * fix(chore): updated deps and moved scripts * feat(typescript): add types and eslint
- Loading branch information
Showing
36 changed files
with
3,343 additions
and
1,681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.now | ||
.github | ||
.env | ||
.eslintrc.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: ["./tsconfig.json"] | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
extends: ["airbnb-typescript/base", "prettier/@typescript-eslint"], | ||
env: { | ||
node: true | ||
}, | ||
rules: { | ||
"no-console": "off" | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const config = { | ||
whiteListedDomains: [ | ||
"https://github.com", | ||
"https://medium.com", | ||
"https://twitter.com" | ||
], | ||
githubFeeds: [ | ||
{ | ||
name: "angular", | ||
repo: "angular/angular", | ||
hasChangelog: true, | ||
feed: "https://github.com/angular/angular/releases.atom" | ||
}, | ||
{ | ||
name: "ionic", | ||
repo: "driftyco/ionic", | ||
hasChangelog: true, | ||
feed: "https://github.com/driftyco/ionic/releases.atom" | ||
}, | ||
{ | ||
name: "nativescript", | ||
repo: "NativeScript/NativeScript", | ||
hasChangelog: true, | ||
feed: "https://github.com/NativeScript/NativeScript/releases.atom" | ||
}, | ||
{ | ||
name: "wengy-ven", | ||
repo: "ngVenezuela/wengy-ven", | ||
hasChangelog: true, | ||
feed: "https://github.com/ngVenezuela/wengy-ven/releases.atom" | ||
} | ||
], | ||
blogFeeds: [ | ||
{ | ||
name: "Blog oficial de ngvenezuela", | ||
feed: "https://dev.to/feed/ngvenezuela" | ||
} | ||
] | ||
}; | ||
|
||
export default config; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const messages: { [index: string]: any } = { | ||
welcome: "Hola #{name}, ¡Bienvenid@ a ngVenezuela!. Te invitamos a ".concat( | ||
"seguirnos en twitter como [@ngVenezuela](https://twitter.com/ngVenezuela) ", | ||
"y a mirar nuestra comunidad en Github: https://github.com/ngvenezuela.\n\n", | ||
"Además nos gustaría que respondieras esta pequeña encuesta: http://bit.ly/ngve-encuesta" | ||
), | ||
goodBye: | ||
"¡Nos vemos pronto #{name}! Esperamos NO verte por el grupo de React Venezuela", | ||
goodMornings: { | ||
mondays: [ | ||
"Buenos días comunidad, ¡Que tengan un excelente inicio de semana! \u{1F60E}" | ||
], | ||
fridays: [ | ||
"Buenos días. Recuerden que los viernes no se hacen deploy \u{1F601}", | ||
"Buenos días. ¡Hoy es viernes y el hardware lo sabe!", | ||
"Buenos días comunidad. Feliz viernes", | ||
"Buenos días. Hoy cualquier bug es un feature después de las 4pm" | ||
], | ||
generic: [ | ||
"Buenos días...¿tomaron café? \u{2615}", | ||
"Buenos días. Recuerden que detrás de una persona exitosa ".concat( | ||
"está una gran cantidad de café \u{2615}" | ||
), | ||
"Buenos días. Keep calm and drink \u{2615}", | ||
"Buenos días \u{1F601}\u{2615}", | ||
"Buenos días", | ||
"Buenos días a todos", | ||
"Buenos días comunidad", | ||
"Buenos días #ngPanas", | ||
"Buenos días comunidad, Y como dice @cesarfrick: ¡A trabajar, ".concat( | ||
"vagos! Que los yates de sus jefes no se pagan solos" | ||
) | ||
] | ||
}, | ||
newBlogPost: "*#{author}* ha agregado una nueva entrada al blog titulada: ".concat( | ||
"*#{title}* y está disponible en: #{link}" | ||
), | ||
newTweet: "#ngVenezuelaTweet \u{1F426}\n".concat( | ||
"#{tweetText}\n", | ||
"----\n", | ||
"Puedes ver el Tweet aquí: #{tweetUrl}" | ||
), | ||
githubRelease: "*#{name}* acaba de alcanzar la versión *#{version}*\n\n".concat( | ||
"[Puedes ver los cambios aquí](#{url})" | ||
), | ||
githubOpenVeLink: | ||
"El enlace de github para comunidades de Telegram es: https://github.com/OpenVE/comunidades-en-telegram", | ||
gistCreated: | ||
"gist creado por #{fullName} #{user} para https://t.me/ngvenezuela con https://github.com/ngVenezuela/wengy-ven", | ||
gistRecommendation: | ||
"Utiliza el comando /gist _codigo_ para generar un gist en github" | ||
}; | ||
|
||
export default messages; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import config from "../config"; | ||
import { forwardMessage, sendMessage } from "./bot-methods"; | ||
import { Chat, Message } from "./interfaces"; | ||
|
||
const { MAIN_GROUP_ID, ADMIN_GROUP_ID } = process.env; | ||
|
||
export const getChatType = async (message: Message) => { | ||
const { | ||
chat: { id: chatId } | ||
} = message; | ||
|
||
if (chatId.toString() === MAIN_GROUP_ID) { | ||
return "main"; | ||
} | ||
|
||
if (chatId.toString() === ADMIN_GROUP_ID) { | ||
return "admin"; | ||
} | ||
|
||
return "private"; | ||
}; | ||
|
||
/** | ||
* Send main or admin's group id. | ||
* This will be used in your .env | ||
*/ | ||
export const sendGroupId = async ({ id: chatId, type }: Chat) => { | ||
if (["group", "supergroup"].includes(type)) { | ||
await sendMessage({ | ||
chatId, | ||
text: `Tú variable \`mainGroupId/adminGroupId\` es: ${chatId}` | ||
}); | ||
} | ||
}; | ||
|
||
export const verifyUrls = async (message: Message) => { | ||
const type = await getChatType(message); | ||
|
||
if (message.text && type === "main") { | ||
const urlEntities = message.entities | ||
? message.entities.filter(entity => entity.type === "url") | ||
: []; | ||
if (urlEntities.length > 0) { | ||
const urls = urlEntities.map(entity => | ||
message | ||
.text!.slice(entity.offset, entity.length + entity.offset) | ||
.replace("https://www.", "https://") | ||
); | ||
|
||
const arePostedUrlsPermitted = urls.every(url => | ||
config.whiteListedDomains.some(whiteListedDomain => | ||
new RegExp(`^${whiteListedDomain}`).test(url) | ||
) | ||
); | ||
|
||
if (arePostedUrlsPermitted && ADMIN_GROUP_ID) { | ||
await forwardMessage({ | ||
chatId: Number(ADMIN_GROUP_ID), | ||
fromChatId: message.chat.id, | ||
messageId: message.message_id | ||
}); | ||
} | ||
} | ||
} | ||
}; |
Oops, something went wrong.