Migrate to TypeScript, minor changes and fixes #46

Merged
ihatenodejs merged 10 commits from typescript into main 2025-04-29 19:39:11 +00:00
ihatenodejs commented 2025-04-24 23:02:32 +00:00 (Migrated from github.com)

This PR migrates Kowalski to TypeScript in an extendable way. Hopefully these changes will help provide a good starting point for building a more stable bot. Some other changes have been made to adapt the bot to TypeScript, though I have been minimal on purpose.

Important Notes

  • Bun must be used instead of Node unless nodemon.json is modified.
  • config.env has been moved to .env
This PR migrates Kowalski to TypeScript in an extendable way. Hopefully these changes will help provide a good starting point for building a more stable bot. Some other changes have been made to adapt the bot to TypeScript, though I have been minimal on purpose. # Important Notes * Bun must be used instead of Node unless `nodemon.json` is modified. * `config.env` has been moved to `.env`
GiovaniFZ (Migrated from github.com) reviewed 2025-04-24 23:08:40 +00:00
@ -0,0 +10,4 @@
const botInfo = await ctx.telegram.getMe();
const startMsg = Strings.botWelcome.replace(/{botName}/g, botInfo.first_name);
ctx.reply(startMsg, {
GiovaniFZ (Migrated from github.com) commented 2025-04-24 23:08:40 +00:00

don't use any, ctx should have a type

don't use any, ctx should have a type
lucmsilva651 (Migrated from github.com) approved these changes 2025-04-24 23:08:41 +00:00
lucmsilva651 (Migrated from github.com) left a comment

Seems good. Approved. Wait for @GiovaniFZ review before merging/squashing.

Seems good. Approved. Wait for @GiovaniFZ review before merging/squashing.
GiovaniFZ (Migrated from github.com) reviewed 2025-04-24 23:09:54 +00:00
@ -0,0 +16,4 @@
async function downloadModule(moduleId: string): Promise<ModuleResult | null> {
try {
const downloadUrl = `${Resources.modArchiveApi}${moduleId}`;
const response = await axios({
GiovaniFZ (Migrated from github.com) commented 2025-04-24 23:09:54 +00:00

instead of using an interface like this, my recommendation is to try to use Zod to make validations better

instead of using an interface like this, my recommendation is to try to use Zod to make validations better
GiovaniFZ (Migrated from github.com) reviewed 2025-04-24 23:12:13 +00:00
@ -0,0 +10,4 @@
const botInfo = await ctx.telegram.getMe();
const startMsg = Strings.botWelcome.replace(/{botName}/g, botInfo.first_name);
ctx.reply(startMsg, {
GiovaniFZ (Migrated from github.com) commented 2025-04-24 23:12:13 +00:00

same applies to bot

same applies to bot
ihatenodejs (Migrated from github.com) reviewed 2025-04-24 23:12:39 +00:00
@ -0,0 +16,4 @@
async function downloadModule(moduleId: string): Promise<ModuleResult | null> {
try {
const downloadUrl = `${Resources.modArchiveApi}${moduleId}`;
const response = await axios({
ihatenodejs (Migrated from github.com) commented 2025-04-24 23:12:39 +00:00

@lucmsilva651 What do you think about this? Using Zod might make things more complex for you to maintain in terms of modifying types.

@lucmsilva651 What do you think about this? Using [Zod](https://zod.dev) might make things more complex for you to maintain in terms of modifying types.
GiovaniFZ (Migrated from github.com) reviewed 2025-04-24 23:17:47 +00:00
@ -0,0 +16,4 @@
async function downloadModule(moduleId: string): Promise<ModuleResult | null> {
try {
const downloadUrl = `${Resources.modArchiveApi}${moduleId}`;
const response = await axios({
GiovaniFZ (Migrated from github.com) commented 2025-04-24 23:17:47 +00:00

@lucmsilva651 we discussed that if you know what is zod and how to use it, @ihatenodejs will do, otherwise not

@lucmsilva651 we discussed that if you know what is zod and how to use it, @ihatenodejs will do, otherwise not
ihatenodejs commented 2025-04-25 14:34:00 +00:00 (Migrated from github.com)

@GiovaniFZ, as you might have seen in #47, @lucmsilva651 is all good with using Zod. I will work on this later today once my classes are finished, though feel free to start!

@GiovaniFZ, as you might have seen in #47, @lucmsilva651 is all good with using Zod. I will work on this later today once my classes are finished, though feel free to start!
ihatenodejs (Migrated from github.com) reviewed 2025-04-26 17:36:45 +00:00
@ -0,0 +10,4 @@
const botInfo = await ctx.telegram.getMe();
const startMsg = Strings.botWelcome.replace(/{botName}/g, botInfo.first_name);
ctx.reply(startMsg, {
ihatenodejs (Migrated from github.com) commented 2025-04-26 17:36:45 +00:00

Working on some of these fixes today. I will also add in types for ctx

Working on some of these fixes today. I will also add in types for `ctx`
ihatenodejs commented 2025-04-26 18:55:45 +00:00 (Migrated from github.com)

@GiovaniFZ @lucmsilva651 Any thoughts on the changes I've made?

@GiovaniFZ @lucmsilva651 Any thoughts on the changes I've made?
lucmsilva651 commented 2025-04-29 04:17:15 +00:00 (Migrated from github.com)

@GiovaniFZ @lucmsilva651 Any thoughts on the changes I've made?

Not really lmao, if it is fixing most of the bot issues, it is fine

> @GiovaniFZ @lucmsilva651 Any thoughts on the changes I've made? Not really lmao, if it is fixing most of the bot issues, it is fine
lucmsilva651 commented 2025-04-29 19:37:43 +00:00 (Migrated from github.com)

@ihatenodejs @GiovaniFZ if you guys are going to implement Zod into this, do another PR or commit to main branch. I know there is more types to add here and there, but I want to do some changes and I can't do it while this PR is open. Merging rn!

:shipit:

@ihatenodejs @GiovaniFZ if you guys are going to implement Zod into this, do another PR or commit to main branch. I know there is more types to add here and there, but I want to do some changes and I can't do it while this PR is open. Merging rn! :shipit:
Sign in to join this conversation.
No description provided.