Skip to content

Commit

Permalink
Merge pull request #40 from beabee-communityrm/feat/user-feedback
Browse files Browse the repository at this point in the history
feat(user-feedback): RS feedback implementations
  • Loading branch information
JumpLink authored Jul 5, 2024
2 parents 64ff582 + 4ecf226 commit 5954536
Show file tree
Hide file tree
Showing 28 changed files with 341 additions and 302 deletions.
2 changes: 1 addition & 1 deletion beabee-client/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beabee-client",
"version": "0.3.2",
"version": "0.3.3",
"tasks": {
"clear": "rm -rf ./dist/",
"dev": "deno run --allow-net --allow-read --allow-write --allow-env --allow-ffi --watch ./mod.ts",
Expand Down
6 changes: 3 additions & 3 deletions beabee-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion beabee-client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@beabee/client",
"description": "The Beabee API Client for Deno, Node.js, and the browser",
"version": "0.3.2",
"version": "0.3.3",
"license": "Apache-2.0",
"type": "module",
"engines": {
Expand Down
11 changes: 7 additions & 4 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"beabee-common"
],
"name": "beabee-telegram-workspace",
"version": "0.3.2",
"version": "0.3.3",
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
Expand All @@ -22,7 +22,10 @@
"sqlite3": "https://deno.land/x/[email protected]/mod.ts",
"@beabee/beabee-common": "./beabee-common/mod.ts",
"@beabee/beabee-client": "../beabee-client/mod.ts",
"date-fns": "npm:[email protected]"
"date-fns": "npm:[email protected]",
"https://lib.deno.dev/x/grammy@^1.20/": "https://lib.deno.dev/x/grammy@^1.26.0/",
"https://deno.land/x/[email protected]/": "https://deno.land/x/[email protected]/",
"https://deno.land/x/[email protected]/": "https://deno.land/x/[email protected]/"
},
"scopes": {
"https://raw.githubusercontent.com/Zhomart/dex/": {
Expand Down Expand Up @@ -62,8 +65,8 @@
"generate:index:beabee-client": "cd beabee-client && deno task generate:index",
"generate:index:beabee-common": "cd beabee-common && deno task generate:index",
"i18n": "cd telegram-bot && deno task i18n",
"docker:build": "docker build -t beabee/telegram-bot:latest . && docker tag beabee/telegram-bot:latest beabee/telegram-bot:0.3.2",
"docker:build": "docker build -t beabee/telegram-bot:latest . && docker tag beabee/telegram-bot:latest beabee/telegram-bot:0.3.3",
"docker:start": "docker run -it --init -p 3003:3003 beabee/telegram-bot:latest",
"docker:push": "docker push beabee/telegram-bot:latest && docker push beabee/telegram-bot:0.3.2"
"docker:push": "docker push beabee/telegram-bot:latest && docker push beabee/telegram-bot:0.3.3"
}
}
6 changes: 3 additions & 3 deletions telegram-bot/commands/help.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export class HelpCommand extends BaseCommand {
}

// Handle the /help command
async action(ctx: AppContext) {
const successful = await this.checkAction(ctx);
if (!successful) {
async action(ctx: AppContext, force = false) {
const successful = await this.checkAction(ctx, force);
if (!force && !successful) {
return false;
}
// Use session.state to get context related help
Expand Down
2 changes: 0 additions & 2 deletions telegram-bot/commands/list.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export class ListCommand extends BaseCommand {
return false;
}

// await this.keyboard.removeLastInlineKeyboard(ctx);

const signal = await this.stateMachine.setSessionState(
ctx,
ChatState.CalloutList,
Expand Down
23 changes: 12 additions & 11 deletions telegram-bot/commands/reset.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ListCommand } from "./index.ts";
import type { AppContext } from "../types/index.ts";

// Temporary constant until it is certain that we want to do this, I am not happy with it because we are no longer able to reset the state to to the `start` state
const SHOW_LIST_AFTER_RESET = true;
const SHOW_LIST_AFTER_DONE = true;

@Singleton()
export class ResetCommand extends BaseCommand {
Expand Down Expand Up @@ -69,7 +69,7 @@ export class ResetCommand extends BaseCommand {
await this.keyboard.removeLastInlineKeyboard(ctx);

// Show list if the constant is set to true
if (SHOW_LIST_AFTER_RESET) {
if (SHOW_LIST_AFTER_DONE) {
await this.communication.send(
ctx,
await this.messageRenderer.continueList(),
Expand All @@ -79,17 +79,18 @@ export class ResetCommand extends BaseCommand {
// successful = successful && await this.stateMachine.resetSessionState(ctx);

successful = successful && await this.listCommand.action(ctx, true);
} else {
// Otherwise show continue help
await this.communication.send(
ctx,
await this.messageRenderer.continueHelp(session.state),
);

// Reset the state and unsubscribe all events
await this.stateMachine.setSessionState(ctx, ChatState.Start, true);
return successful;
}

// Otherwise show continue help
await this.communication.send(
ctx,
await this.messageRenderer.continueHelp(session.state),
);

// Reset the state and unsubscribe all events
await this.stateMachine.setSessionState(ctx, ChatState.Start, true);

return successful;
}
}
20 changes: 16 additions & 4 deletions telegram-bot/commands/show.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@ export class ShowCommand extends BaseCommand {
}

try {
// const session = await ctx.session;
const callout = await this.callout.get(slug);
const render = await this.calloutRenderer.calloutDetails(callout);
const callout = await this.callout.get(slug, ["form"]);
const calloutDetailsRender = await this.calloutRenderer.calloutDetails(
callout,
);
const calloutIntroRender = this.calloutRenderer.intro(
callout,
);
const calloutStartResponseKeyboard = this.calloutRenderer
.startResponseKeyboard(
callout,
);

const signal = await this.stateMachine.setSessionState(
ctx,
Expand All @@ -65,7 +73,11 @@ export class ShowCommand extends BaseCommand {
throw new Error("The AbortSignal is required!");
}

await this.communication.sendAndReceiveAll(ctx, render, signal);
await this.communication.sendAndReceiveAll(ctx, [
calloutDetailsRender,
calloutIntroRender,
calloutStartResponseKeyboard,
], signal);
} catch (error) {
console.error("Error sending callout", error);
successful = false;
Expand Down
4 changes: 2 additions & 2 deletions telegram-bot/commands/start.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { START_CALLOUT_PREFIX } from "../constants/index.ts";

import type { AppContext } from "../types/index.ts";

const SHOW_LIST_AFTER_START = true;
const SHOW_LIST_AFTER_DONE = true;

@Singleton()
export class StartCommand extends BaseCommand {
Expand Down Expand Up @@ -59,7 +59,7 @@ export class StartCommand extends BaseCommand {
await this.communication.send(ctx, this.messageRenderer.welcome());

// Show list if the constant is set to true
if (SHOW_LIST_AFTER_START) {
if (SHOW_LIST_AFTER_DONE) {
const successful = await this.listCommand.action(ctx, true);
return successful;
}
Expand Down
4 changes: 2 additions & 2 deletions telegram-bot/constants/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export const INLINE_BUTTON_CALLBACK_PREFIX = "callback_query:data";
// Note: We choose short strings here because the length of these strings is limited in the Telegram bot API
// and the slug is appended here.The max allowed size of a callback string is 64 bytes.
export const INLINE_BUTTON_CALLBACK_SHOW_CALLOUT = "1";
export const INLINE_BUTTON_CALLBACK_CALLOUT_INTRO = "2";
export const INLINE_BUTTON_CALLBACK_CALLOUT_PARTICIPATE = "3";
export const INLINE_BUTTON_CALLBACK_CALLOUT_PARTICIPATE = "2";
export const INLINE_BUTTON_CALLBACK_CALLOUT_LIST = "3";

/**
* Prefix for the callout response interaction events, used for skip and done inline buttons, perhaps useful for others.
Expand Down
11 changes: 7 additions & 4 deletions telegram-bot/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telegram-bot",
"version": "0.3.2",
"version": "0.3.3",
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
Expand All @@ -14,7 +14,10 @@
"sqlite3": "https://deno.land/x/[email protected]/mod.ts",
"date-fns": "npm:[email protected]",
"@beabee/beabee-common": "../beabee-common/mod.ts",
"@beabee/beabee-client": "../beabee-client/mod.ts"
"@beabee/beabee-client": "../beabee-client/mod.ts",
"https://lib.deno.dev/x/grammy@^1.20/": "https://lib.deno.dev/x/grammy@^1.26.0/",
"https://deno.land/x/[email protected]/": "https://deno.land/x/[email protected]/",
"https://deno.land/x/[email protected]/": "https://deno.land/x/[email protected]/"
},
"scopes": {
"https://raw.githubusercontent.com/Zhomart/dex/": {
Expand All @@ -33,9 +36,9 @@
"check:format": "deno task format --check",
"check:types": "deno check main.ts",
"cache": "deno cache --reload main.ts",
"docker:build": "docker build -f ../Dockerfile -t beabee/telegram-bot:latest .. && docker tag beabee/telegram-bot:latest beabee/telegram-bot:0.3.2",
"docker:build": "docker build -f ../Dockerfile -t beabee/telegram-bot:latest .. && docker tag beabee/telegram-bot:latest beabee/telegram-bot:0.3.3",
"docker:start": "docker run -it --init -p 3003:3003 beabee/telegram-bot",
"docker:push": "docker push beabee/telegram-bot:latest && docker push beabee/telegram-bot:0.3.2",
"docker:push": "docker push beabee/telegram-bot:latest && docker push beabee/telegram-bot:0.3.3",
"i18n": "deno run --allow-read --allow-write --allow-env --allow-net scripts/i18n.ts && deno task format"
}
}
Loading

0 comments on commit 5954536

Please sign in to comment.