Migrate to TypeScript, minor changes and fixes #46
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: ABOCN/TelegramBot#46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "typescript"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
nodemon.json
is modified.config.env
has been moved to.env
@ -0,0 +10,4 @@
const botInfo = await ctx.telegram.getMe();
const startMsg = Strings.botWelcome.replace(/{botName}/g, botInfo.first_name);
ctx.reply(startMsg, {
don't use any, ctx should have a type
Seems good. Approved. Wait for @GiovaniFZ review before merging/squashing.
@ -0,0 +16,4 @@
async function downloadModule(moduleId: string): Promise<ModuleResult | null> {
try {
const downloadUrl = `${Resources.modArchiveApi}${moduleId}`;
const response = await axios({
instead of using an interface like this, my recommendation is to try to use Zod to make validations better
@ -0,0 +10,4 @@
const botInfo = await ctx.telegram.getMe();
const startMsg = Strings.botWelcome.replace(/{botName}/g, botInfo.first_name);
ctx.reply(startMsg, {
same applies to bot
@ -0,0 +16,4 @@
async function downloadModule(moduleId: string): Promise<ModuleResult | null> {
try {
const downloadUrl = `${Resources.modArchiveApi}${moduleId}`;
const response = await axios({
@lucmsilva651 What do you think about this? Using Zod might make things more complex for you to maintain in terms of modifying types.
@ -0,0 +16,4 @@
async function downloadModule(moduleId: string): Promise<ModuleResult | null> {
try {
const downloadUrl = `${Resources.modArchiveApi}${moduleId}`;
const response = await axios({
@lucmsilva651 we discussed that if you know what is zod and how to use it, @ihatenodejs will do, otherwise not
@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!
@ -0,0 +10,4 @@
const botInfo = await ctx.telegram.getMe();
const startMsg = Strings.botWelcome.replace(/{botName}/g, botInfo.first_name);
ctx.reply(startMsg, {
Working on some of these fixes today. I will also add in types for
ctx
@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
@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: