Access Control Setup Part 2

We've set the permissions of the users, but we need to decide on the level of permission needed for the commands & then have them ready to compare to the user when a telgram bot "/command" is recieved. We'll deal with that process a little later. For now, let's create a command, with the permission level needed to run it. We'll also cover the instructions for updating the permission level, deleting the command &, of course, listing the commands that our bot knows.

Create a command

Add an inject node & link it to the database (as above). You did create the command table when you set the database up, didn't you?

Set up the inject node as you can see in the picture. Obviously you'll need to change the exact details in the fields to match the command you're adding. Those payload items that you can't quite read are the ones used when the table was set up
msg.payload.command
msg.payload.permission

The msg.topic is

INSERT into command (`command`, `permission`) VALUES (:command, :permission)

How to update the permission level of a command

Exactly the same way as we did with updating a user (using msg.topic = UPDATE command SET permission= 7 WHERE command = '/services')

How to delete a command

Or a user if you change the msg.topic! The node is the same setup as above, but change the msg.topic to suit (the bot command  specified at the end of the line in "" is the one that is deleted)

DELETE FROM command WHERE command = "/services"

How to list the commands that I have

Another inject node, set up the same as the two above, but with the msg.topic set to

select * from command

You'll be able to see the output in the debug console, as long as you attached one. (See the first picture if you aren't sure about where it goes, although if you've got this far I doubt that you need the help)

Now you need to know how to handle the commands.