Controlling the feeder via night bot chat

Asked Nov 29, 2023·1 reply·Last activity 2 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hi all!
I have a bird feeder that is controlled via the Internet. She has her own dedicated IP.

I want to teach a night bot to turn on the feeder if a viewer writes the command “on” in the chat.
I launched a Python webhook + flask on a remote server.
How can I make a bot command so that it sends a command and username to the webhook address? There I could handle her and send a command to the feeding trough. I'm just learning Python and it's hard for me to figure out how to do this.

1 reply

Hiya, thats cool!

You can use the UrlFetch variable: https://docs.nightbot.tv/variables/urlfetch
Nighbot will send a GET request to the provided url. You can either response with a plain text chat message directly, or return a space " " for no comfirmation message.

There is alot of info in the headers from the Nightbot request, about the user, the channel, and a link to send a Chat message. But you can also simply add and retrieve user information in the url, for example:
$(urlfetch https://test.com/?username=$(user))