Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] /price command #36

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ var commands = {
{
'name': "charge",
'desc': 'Charge amount on someone'
},
{
'name': "price",
'desc': 'Show current group\'s item prices'
}
]
}
Expand Down Expand Up @@ -113,7 +117,6 @@ bot.on(`/${commands.list[4].name}`, (msg) => {

// /balance command
bot.on(`/${commands.list[5].name}`, (msg) => {
let tmpMsg = ""
let table = new ascii().setHeading("Users", "Wallets")

Object.values(users[msg.chat.id]).forEach(element =>
Expand Down Expand Up @@ -180,6 +183,18 @@ bot.on([new RegExp('^\/'+`${commands.list[7].name}`+' (@.+) (-?\\d+)'), new RegE
}
})

// /price command
bot.on(`/${commands.list[8].name}`, (msg) => {
let table = new ascii().setHeading("Item", "Current price")

table.addRow(`Box`, `${prices[msg.chat.id].box} CHF`)
table.addRow(`Bottle`, `${prices[msg.chat.id].bottle} CHF`)

msg.reply.text(`Here are the current prices in your group for your items :`)
bot.sendMessage(msg.chat.id, '```\n' + table.toString() + '\n```', {parseMode: 'Markdown'})
table = ""
})

// /dump command
bot.on('/dump', async (msg) => {
return bot.sendDocument(msg.from.id, 'users_data.json')
Expand Down