-2

I currently have a telegram bot giving my organisation users answers to FAQ questions but I need to restrict it so only certain people that have paid for the mentorship are able to use the product

is there anyway I can ask people to enter a user id number that stores the information in so if there not on the list in the code there cant access the bot

my bot is currently written in nodejs language (based on this repo).

[
    {
        "triggers": [
            "hello",
            "hi"
        ],
        "replies": [
            {
                "reply": "Hi Im your Personal Lion Bot \r\n\r\nWhat do you want to focus on today\r\n\r\n>Trading Help\r\n\r\n>Business Help\r\n\r\n>Mindset\r\n\r\n>Schedule\r\n\r\n>Just Started\r\n\r\n>Help",
                "type": "text"
            }
        ]
    },
    {
        "triggers": [
            "trading",
            "Trading"
        ],
        "replies": [
            {
                "reply": "Ok you want to focus on trading\r\n\r\nHeres is what I can show you\r\n\r\n>Our Schedule\r\n\r\n>A Trading Gameplan\r\n\r\n>Trade Ideas\r\n\r\n>Trading Products",
                "type": "text"
            }
        ]
    }
]
Tibebes. M
  • 6,940
  • 5
  • 15
  • 36
AlShan
  • 1
  • 3

1 Answers1

0

You need to know your paying users' ID, then you answer their messages only if msg.from.id is in your list of allowed users.

Something like:

function check_if_allowed(id) {
  ...
}

bot.on('message', (msg) => {
  if (check_if_allowed(msg.from.id)) {
    ...
  }
})

To find their ID depends on how you register them in your organization.

Add more details and code if you need further help

ej1
  • 66
  • 4
  • Thank you How do you make the actual List sorry I’m totally new to this – AlShan Jun 20 '20 at 14:09
  • @AlShan Apart from making the list, if the above answer is correct please mark it as accepted, so others can use it. It would be a good idea to implement the answer with a fake list and see if it works. Then you should open a new thread asking how to capture user id after subscription – ej1 Jun 21 '20 at 14:35
  • @AlShan It really depends on how you process the users that pay for mentorship. If they buy it from a web page, then you could give them an invite link like t.me/mentorship_bot?start=123456 and then you read the code when you process the /start command, and associate this code to the user id. Tell more about your process and show your code if you need more help – ej1 Jun 21 '20 at 16:37