Skip to content

Commit a938a00

Browse files
committed
simplified web worker launch process + adapted to next client version
1 parent 4a9a291 commit a938a00

File tree

22 files changed

+327
-338
lines changed

22 files changed

+327
-338
lines changed

docs/telegram-bot-playground/assets/index-BdFVq0_I.js

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/telegram-bot-playground/assets/index-D5yhjlgw.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/telegram-bot-playground/assets/web-worker-BcVFCjdL.js

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/telegram-bot-playground/assets/web-worker-DkORvJaQ.js

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { BotMessageHandlers } from "@effect-ak/tg-bot-client"
1+
import { BotResponse, defineBot } from "@effect-ak/tg-bot-client"
22

3-
export default {
3+
export default defineBot({
44
on_message: (msg) => {
55

66
const commandEntity = msg.entities?.find(_ => _.type == "bot_command");
@@ -9,27 +9,28 @@ export default {
99
console.log("command", command);
1010

1111
if (command == "/bye") {
12-
return {
12+
return BotResponse.make({
1313
type: "message",
1414
text: "See you later!"
15-
}
15+
});
1616
}
1717

1818
if (command == "/echo") {
19-
return {
19+
return BotResponse.make({
2020
type: "message",
2121
text: `<pre language="json">${JSON.stringify(msg, undefined, 2)}</pre>`,
2222
parse_mode: "HTML"
23-
}
23+
})
2424
}
2525

2626
if (msg.text) { // reply with "hey" on any text message
27-
return {
27+
return BotResponse.make({
2828
type: "message",
2929
text: "hey 😇"
30-
}
30+
})
3131
}
3232

33-
},
34-
} satisfies BotMessageHandlers
33+
return BotResponse.ignore
3534

35+
},
36+
})
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import type { BotMessageHandlers } from "@effect-ak/tg-bot-client"
1+
import { BotResponse, defineBot } from "@effect-ak/tg-bot-client"
22

3-
export default {
3+
export default defineBot({
44
on_message: (msg) => {
55

66
if (msg.text) {
7-
return {
7+
return BotResponse.make({
88
type: "message",
99
text: "hey 😀"
10-
}
10+
})
1111
}
1212

13+
return BotResponse.ignore;
14+
1315
},
14-
} satisfies BotMessageHandlers
16+
})
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
import type { BotMessageHandlers } from "@effect-ak/tg-bot-client"
1+
import { BotResponse, defineBot } from "@effect-ak/tg-bot-client"
22

3-
export default {
3+
export default defineBot({
44
on_message: (msg) => {
55
if (msg.text?.includes("+")) {
66
const numbers = msg.text.split("+");
77
let result = 0;
88
for (const num of numbers) {
99
result += parseInt(num);
1010
}
11-
return {
11+
return BotResponse.make({
1212
type: "document",
1313
caption: "sum result",
1414
document: {
1515
file_content: new TextEncoder().encode(`your sum is ${result}`),
1616
file_name: "hello.txt"
1717
}
18-
}
18+
})
1919
}
2020

2121
if (msg.text) { //reply on any text message
22-
return {
22+
return BotResponse.make({
2323
type: "message",
2424
text: "hey 🙃, send me a message in the format '3+3+3' and I will return you the sum of it in a text file"
25-
}
25+
})
2626
}
2727

28+
return BotResponse.ignore;
29+
2830
},
29-
} satisfies BotMessageHandlers
31+
})

docs/telegram-bot-playground/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<link rel="icon" type="image/png" sizes="32x32" href="./favicon.ico">
1010

1111

12-
<script type="module" crossorigin src="./assets/index-D5yhjlgw.js"></script>
12+
<script type="module" crossorigin src="./assets/index-BdFVq0_I.js"></script>
1313
<link rel="stylesheet" crossorigin href="./assets/index-BzQa5oof.css">
1414
</head>
1515

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "module",
44
"dependencies": {
55
"@edge-runtime/vm": "^5.0.0",
6-
"@effect-ak/tg-bot-client": "file://Users/alex/projects/effect-ak-org/tg-bot-client/effect-ak-tg-bot-client-0.3.3.tgz",
6+
"@effect-ak/tg-bot-client": "^0.5.1",
77
"@monaco-editor/loader": "^1.4.0",
88
"@types/alpinejs": "^3.13.11",
99
"@types/node": "^22.10.5",

pnpm-lock.yaml

Lines changed: 156 additions & 154 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)