Skip to content

Commit

Permalink
Fixed discord token
Browse files Browse the repository at this point in the history
  • Loading branch information
suhodolskiy committed Sep 3, 2018
1 parent 1f75fee commit 03143c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
.serverless
.idea
package-lock.json
.DS_Store
13 changes: 8 additions & 5 deletions handler.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const axios = require('axios')
const vkGroupId = parseInt(process.env.VK_GROUP_ID)

module.exports.vk = async (event, context, callback) => {
const data = JSON.parse(event.body)

switch (data.type) {
case 'confirmation':
if (data.group_id === vkGroupId) {
if (data.group_id === parseInt(process.env.VK_GROUP_ID)) {
callback(null, {
statusCode: 200,
body: process.env.VK_CONFIRM_CODE,
Expand All @@ -16,8 +15,7 @@ module.exports.vk = async (event, context, callback) => {
}
break
case 'wall_post_new':
let { id, owner_id, post_type, attachments, text } = data

let { id, owner_id, post_type, attachments, text } = data.object
if (text && text.indexOf('@rnative') !== -1 && post_type === 'post') {
let isHelpPost = false
let embed = {}
Expand Down Expand Up @@ -50,6 +48,11 @@ module.exports.vk = async (event, context, callback) => {
text,
embed
)

callback(null, {
statusCode: 200,
body: 'ok',
})
}

callback(null, { success: true })
Expand All @@ -61,7 +64,7 @@ const sendMessageToDiscordChannel = (channel, content, embed) =>
axios({
url: `https://discordapp.com/api/channels/${channel}/messages`,
headers: {
Authorization: `Bot ${process.env.DISCORD_CONTENT}`,
Authorization: `Bot ${process.env.DISCORD_TOKEN}`,
'Content-Type': 'application/json',
},
method: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ service: aws-rnative-bot

provider:
name: aws
runtime: nodejs6.10
runtime: nodejs8.10
stage: dev
region: eu-west-3

Expand Down

0 comments on commit 03143c2

Please sign in to comment.