Telegram admins

I am trying to create a command that only responds to administrators.
how should i set the command to get an array of all admin?

The /command node should return the property
msg.originalMessage.from.id this will be who sent the command use it to compare it to the admins id to filter /commands for others.

To use the getChatAdministrators method, you can send a http request as below

[{"id":"b1175572.28c0d8","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":340,"wires":[["5a160730.12f4f8"]]},{"id":"5a160730.12f4f8","type":"http request","z":"c791cbc0.84f648","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.telegram.org/bot12DGHHGRF56FQ_Vgg6SNzs3LzFW_525Kmrl-ilr5EfE/getChatAdministrators?chat_id=-1003456774444","tls":"","persist":false,"proxy":"","authType":"","x":350,"y":320,"wires":[["e68bb3e2.78de2"]]},{"id":"e68bb3e2.78de2","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":340,"wires":[]}]

should return

{"ok":true,"result":[{"user":{"id":8592451409,"is_bot":true,"first_name":"mybot","username":"e1cidbot"},"status":"administrator","can_be_edited":false,"can_manage_chat":true,"can_change_info":true,"can_delete_messages":true,"can_invite_users":true,"can_restrict_members":true,"can_pin_messages":true,"can_promote_members":false,"can_manage_voice_chats":true,"custom_title":"Boss","is_anonymous":true},{"user":{"id":274758257,"is_bot":false,"first_name":"ElCid","language_code":"en"},"status":"creator","is_anonymous":false}]}

can I get the admin list only through the webhook?

I have not seen any way to get it from the telegram node But others may know differently. If there was the telegram node would use a http call or web sockets to do the same thing.

You would only need to do the http call once a day (or similar) to store admin id's

to which address should I bind the token to get the webhook for node-red?

Look in the http request node the full url is there. Just change the bot secret key and the chat_id.

Yes, thank you. It's working. I just have to filter the playolad. I was expecting an array.

Try this JSONata expression in a change node, it should return an array of id's
Set msg.what_ever
to J:

[**.id]

I tested the proposed solution but it had no result

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.