How To Listen For Things Using Gram-JS #467
thepeanutgalleryandco
started this conversation in
General
Replies: 1 comment 5 replies
-
This is a demonstration of a GramJS exquivalent of what you’re talking about: import { NewMessage } from "telegram/events";
client.addEventHandler(async (event) => {
// Use the args from event.message.patternMatch.
await event.message.reply({ text: "Thanks, registered!" });
}, new NewMessage({ pattern: /^\/register(@yourBotUsername|) ([0-9]+)$/ }));
await client.start({ ... });
// Call your async function to setup commands. Note that GramJS is communicating directly to MTProto API which provides a lower-level interface for building Telegram clients. If you focus mainly on bots, and want to build highly extensible ones, you might want to use a framework like grammY. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Everyone,
I have ran through so many pages and sites over the past couple of days, and would really like to request some help. I have done a Discord bot before, where I do the following, which I would really like to be able to do something similar here for Telegram, but I seem to keep on being stuck.
Discord Bot 1:
Discord Bot 2:
As can be seen, I connect my bot in discord and then I can run something once off, like when the bot is ready from the ready event and then I can also run specific actions when there is a message ('interactionCreate') event specific to my bot.
How do I go about something like this for my Telegram bot?
High level steps:
Thanks in advance for anyone willing to assist!
I am using Javascript / NodeJS as my backend.
Thanks,
Rohan
Beta Was this translation helpful? Give feedback.
All reactions