Skip to content

Commit

Permalink
Merge pull request Desenvolvimento-de-Software#23 from mleandrojr/master
Browse files Browse the repository at this point in the history
Removed the nl to br parser and changed the message sending structure.
  • Loading branch information
mleandrojr authored Aug 1, 2024
2 parents da2ee81 + 7f4efb4 commit 4824231
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/action/Greetings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export default class Greetings extends Action {
}

text = text.replace("{userid}", this.context.newChatMember!.getId());
text = text.replace(/\n/g, "<br>");
text = text.replace(
"{username}",
this.context.newChatMember?.getFirstName() || this.context.newChatMember?.getUsername()
Expand Down
1 change: 0 additions & 1 deletion src/command/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export default class Rules extends Command {
return this.context.chat.sendMessage(Lang.get("rulesNotFound"));
}

const text = result[0].rules.replace(/\n/g, "<br>");
return this.context.chat.sendMessage(result[0].rules, { parseMode: "HTML" });
}

Expand Down
29 changes: 21 additions & 8 deletions src/library/telegram/context/Chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,16 @@ export default class Chat {
sendMessage.setOptions(options);
}

return sendMessage.post()
.then((response) => response.json())
.then((json) => new Message(json.result))
.catch((error) => console.error(error));
try {

const response = await sendMessage.post();
return await response.json();

} catch (error: any) {
Log.save(error.message);
}

return Promise.resolve();
}

/**
Expand All @@ -457,9 +463,16 @@ export default class Chat {
sendChatAction.setThreadId(this.context.messageThreadId);
}

return sendChatAction.post()
.then((response) => response.json())
.then((json) => new Message(json.result))
.catch((error) => console.error(error));
try {

const response = await sendChatAction.post();
console.log(response);
return await response.json();

} catch (error: any) {
Log.save(error.message);
}

return Promise.resolve();
}
}

0 comments on commit 4824231

Please sign in to comment.