Skip to content

Commit

Permalink
Merge pull request #24 from epfl-dojo/feature/drink
Browse files Browse the repository at this point in the history
[FT.] New command (/drink)
  • Loading branch information
JaavLex authored Dec 20, 2019
2 parents ae43807 + da34cb9 commit 6d4cdb0
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@ bot.on('text', async (msg) => {
})

var commands = {
'list': [
{
'name': "start",
'desc': 'Welcome command'
},
{
'name': "help",
'desc': 'Shows a list of available commands'
},
{
'name': "setprice",
'desc': 'Sets the price of a box or a bottle of mate'
}
]
}
'list': [{
'name': "start",
'desc': 'Welcome command'
},
{
'name': "help",
'desc': 'Shows a list of available commands'
},
{
'name': "setprice",
'desc': 'Sets the price of a box or a bottle of mate'
},
{
'name': "drink",
'desc': 'The user drinks a club-mate.'
}
]
}

// /start command
bot.on([`/${commands.list[0].name}`], (msg) => {
Expand Down Expand Up @@ -82,6 +85,18 @@ bot.on([`/${commands.list[2].name}`], (msg) => {
}
});

// /drink command
bot.on([`/${commands.list[3].name}`], (msg) => {
msg.reply.text("Cheers " + users[msg.chat.id][msg.from.id].username + "!!")
console.log(users[msg.chat.id][msg.from.id].wallet);
users[msg.chat.id][msg.from.id].wallet += 2
fs.writeFile('./users_data.json', JSON.stringify(users, null, 2), 'utf8', function(err) {
if (err) {
return console.log(err)
}
})
});

// bot.on(/^\/send(.+)$/, (msg, props) => {
// const value = props.match[1].trim()
// console.log(value)
Expand Down

0 comments on commit 6d4cdb0

Please sign in to comment.