Skip to content

Commit

Permalink
Merge pull request #11 from Astrian/dev
Browse files Browse the repository at this point in the history
Add /help
  • Loading branch information
Astrian Zheng authored Apr 8, 2019
2 parents e95141a + 577aca7 commit 665a0a6
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ telegrafbot.telegram.setWebhook(process.env.DOMAIN + process.env.RANDOM_ADDRESS)
telegrafbot.command('start', async (ctx) => {
try {
let info = await API.checkpoc(ctx.message.from.id)
telegrambot.sendMessage(ctx.message.from.id, `欢迎你,${info.location}${info.faction} 签到人员。\n\n/importrsvp - 导入你所在阵营的特工\n/checkin - 进行签到\n/checkout - 进行签退`, {parse_mode: "Markdown"})
telegrambot.sendMessage(ctx.message.from.id, `欢迎你,${info.location}${info.faction} 签到人员。\n\n/importrsvp - 导入你所在阵营的特工\n/checkin - 进行签到\n/checkout - 进行签退\n/help - 寻求帮助`, {parse_mode: "Markdown"})
} catch (err) {
telegrambot.sendMessage(ctx.message.from.id, err, {parse_mode: "Markdown"})
}
Expand Down Expand Up @@ -105,6 +105,9 @@ telegrafbot.command('importrsvp', async (ctx) =>{
try {
let info = await API.checkpoc(ctx.message.from.id)

// check up poc info and ap logging status
await API.checkapstatus(info.faction, info.location, ctx.message.from.id)

// if user only send the '/importrsvp' command, reply the help infomation
if (ctx.message.text.slice(12) === '') {
let reply = ''
Expand Down Expand Up @@ -132,6 +135,44 @@ telegrafbot.command('importrsvp', async (ctx) =>{
telegrambot.sendMessage(ctx.message.from.id, err, {parse_mode: "Markdown"})
}
})
telegrafbot.command('help', async (ctx) =>{
try {
let info = await API.checkpoc(ctx.message.from.id)

// check up poc info and ap logging status
await API.checkapstatus(info.faction, info.location, ctx.message.from.id)

let message = '需要帮助吗?这些链接可能可以帮到你。\n'
telegrambot.sendMessage(
ctx.message.from.id,
message,
{
parse_mode: "Markdown",
reply_markup: {
inline_keyboard: [
[{
text: '查阅帮助文档',
url: `https://github.com/Astrian/IFS-RSVP-Bot/wiki`
}],
[{
text: '订阅频道',
url: `https://t.me/ifsrsvpbot`
}],
[{
text: '加入反馈群',
url: `https://t.me/joinchat/A0P0mxHipaEeJ-4vzKgTuQ`
}]
]
}
}
)

} catch (err) {
console.log('error accourd!')
console.log(err)
telegrambot.sendMessage(ctx.message.from.id, err, {parse_mode: "Markdown"})
}
})

// Inline button
telegrafbot.on('callback_query', async (ctx) => {
Expand Down

0 comments on commit 665a0a6

Please sign in to comment.