portfoliofoki.blogg.se

Slack bot python
Slack bot python










Slack bot python how to#

One of the first things that came to mind when building the bot is how will users know how to run the bot? I created the following method to solve that little problem. The NET_BLOCK class attribute is just there so the bot can respond with some generic message to the user. In reality this would be an environment variable or pulled from a secure source. I kept it simple and created some credentials for authentication as class attributes. Essentially things in the program that wont change. The variables you see in all caps are called class attributes/constants. "Getting interface information for device :slightly_smiling_face:"ĭef _init_(self, channel, device_name):Ī few things to note. In this case we will call it NetBot, but you can name your bot whatever you like. It only made sense to me to create a separate class to define our network engineering bot. The initial code from Masons example has you create a class called CoinBot. I’ll try not to repeat information that was already shared in Masons post.

slack bot python

Lets walk through some code and I hope to answer how those goals were met. Ability to call different (non static) devices.Network Engineering Botīelow are a few of the goals I had when creating this bot. I hope you enjoy and maybe get inspired to build something you can use to assist you in your daily workflow. What I will demonstrate in this post is what made sense to me at this point in time. I’m a fairly novice python user, expect to see areas where code can be refactored and even total rewrites that would make the organization better. Think of that post as a prerequisite to get you started before following along with this one. After coming across a fantastic post by Mason Egger at Digital Ocean (linked at the end), I figured now is as good a time as any. I’ve wanted to mess with getting a bot running on Slack for a while now.

slack bot python

Hello and thank you for joining me in another blog post.










Slack bot python