mirror of
https://github.com/elisspace/FxLifeSheet.git
synced 2026-08-29 15:44:00 +00:00
Put things in place for editing a message once Telegram supports it
Fixes https://github.com/KrauseFx/FxLifeSheet/issues/44 (kinda)
This commit is contained in:
27
app.js
27
app.js
@@ -312,7 +312,9 @@ function initBot() {
|
||||
}
|
||||
});
|
||||
bot.start(function (ctx) { return ctx.reply("Welcome to FxLifeSheet"); });
|
||||
bot.help(function (ctx) { return ctx.reply("TODO: This will include the help section"); });
|
||||
bot.help(function (ctx) {
|
||||
return ctx.reply("No in-bot help right now, for now please visit https://github.com/KrauseFx/FxLifeSheet");
|
||||
});
|
||||
bot.on("sticker", function (ctx) { return ctx.reply("Sorry, I don't support stickers"); });
|
||||
bot.hears("hi", function (ctx) { return ctx.reply("Hey there"); });
|
||||
// has to be last
|
||||
@@ -344,11 +346,22 @@ function insertNewValue(parsedUserValue, ctx, key, type) {
|
||||
ctx.reply("Error saving value: " + error);
|
||||
}
|
||||
}
|
||||
// TODO: replace with editing the existing message (ID in currentlyAskedQuestionMessageId, however couldn't get it to work)
|
||||
// if (ctx) {
|
||||
// // we don't use this for location sending as we have many values for that
|
||||
// ctx.reply("Success ✅", Extra.inReplyTo(currentlyAskedQuestionMessageId));
|
||||
// }
|
||||
if (ctx) {
|
||||
// we don't use this for location sending as we have many values for that, so that's when `ctx` is nil
|
||||
// Show that we saved the value
|
||||
// Currently the Telegram API doens't support updating of messages that have a custom keyboard
|
||||
// for no good reason, as mentioned here https://github.com/TelegramBots/telegram.bot/issues/176
|
||||
//
|
||||
// Bad Request: Message can't be edited
|
||||
//
|
||||
// Please note, that it is currently only possible to edit messages without reply_markup or with inline keyboards
|
||||
// ctx.telegram.editMessageText(
|
||||
// ctx.update.message.chat.id,
|
||||
// currentlyAskedQuestionMessageId,
|
||||
// null,
|
||||
// "✅ " + lastQuestionAskedDupe + " ✅"
|
||||
// );
|
||||
}
|
||||
});
|
||||
if (key == "mood") {
|
||||
// we only serve the current mood via an API
|
||||
@@ -510,7 +523,7 @@ function initScheduler() {
|
||||
function initMoodAPI() {
|
||||
// needed for the API endpoint used by https://whereisfelix.today
|
||||
// Fetch the last entry from the before the container was spawned
|
||||
// From then on the cashe is refreshed when the user enters the value
|
||||
// From then on the cache is refreshed when the user enters the value
|
||||
var currentMood = rawDataSheet.getRows({
|
||||
offset: 0,
|
||||
limit: 1,
|
||||
|
||||
31
app.ts
31
app.ts
@@ -200,6 +200,7 @@ function triggerNextQuestionFromQueue(ctx) {
|
||||
|
||||
let question =
|
||||
currentlyAskedQuestionObject.question + " (" + questionAppendix + ")";
|
||||
|
||||
ctx.reply(question, keyboard).then(({ message_id }) => {
|
||||
currentlyAskedQuestionMessageId = message_id;
|
||||
});
|
||||
@@ -425,7 +426,11 @@ function initBot() {
|
||||
|
||||
bot.start(ctx => ctx.reply("Welcome to FxLifeSheet"));
|
||||
|
||||
bot.help(ctx => ctx.reply("TODO: This will include the help section"));
|
||||
bot.help(ctx =>
|
||||
ctx.reply(
|
||||
"No in-bot help right now, for now please visit https://github.com/KrauseFx/FxLifeSheet"
|
||||
)
|
||||
);
|
||||
bot.on("sticker", ctx => ctx.reply("Sorry, I don't support stickers"));
|
||||
bot.hears("hi", ctx => ctx.reply("Hey there"));
|
||||
|
||||
@@ -461,11 +466,23 @@ function insertNewValue(parsedUserValue, ctx, key, type) {
|
||||
ctx.reply("Error saving value: " + error);
|
||||
}
|
||||
}
|
||||
// TODO: replace with editing the existing message (ID in currentlyAskedQuestionMessageId, however couldn't get it to work)
|
||||
// if (ctx) {
|
||||
// // we don't use this for location sending as we have many values for that
|
||||
// ctx.reply("Success ✅", Extra.inReplyTo(currentlyAskedQuestionMessageId));
|
||||
// }
|
||||
|
||||
if (ctx) {
|
||||
// we don't use this for location sending as we have many values for that, so that's when `ctx` is nil
|
||||
// Show that we saved the value
|
||||
// Currently the Telegram API doens't support updating of messages that have a custom keyboard
|
||||
// for no good reason, as mentioned here https://github.com/TelegramBots/telegram.bot/issues/176
|
||||
//
|
||||
// Bad Request: Message can't be edited
|
||||
//
|
||||
// Please note, that it is currently only possible to edit messages without reply_markup or with inline keyboards
|
||||
// ctx.telegram.editMessageText(
|
||||
// ctx.update.message.chat.id,
|
||||
// currentlyAskedQuestionMessageId,
|
||||
// null,
|
||||
// "✅ " + lastQuestionAskedDupe + " ✅"
|
||||
// );
|
||||
}
|
||||
});
|
||||
|
||||
if (key == "mood") {
|
||||
@@ -676,7 +693,7 @@ function initScheduler() {
|
||||
function initMoodAPI() {
|
||||
// needed for the API endpoint used by https://whereisfelix.today
|
||||
// Fetch the last entry from the before the container was spawned
|
||||
// From then on the cashe is refreshed when the user enters the value
|
||||
// From then on the cache is refreshed when the user enters the value
|
||||
let currentMood = rawDataSheet.getRows(
|
||||
{
|
||||
offset: 0,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"scripts": {
|
||||
"prettier": "prettier app.ts --write",
|
||||
"dev": "source .keys && prettier app.ts --write && tsc app.ts && node inspect app.js",
|
||||
"dev": "source .keys && prettier app.ts --write && tsc app.ts && node --inspect app.js",
|
||||
"prod": "prettier app.ts --write && tsc app.ts && NODE_ENV=production node app.js"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user