My Experience Learning Python
My Experiance Learning Python
The hard way
I recently decided to pull the trigger and get a Rasberry Pi . With the recent release of the Pi 3 B+ the Pi was finnaly to a point where it had the power and features to support most projects I would do. Then reading a post from @jackdub, using ESP to control electrical outlets from a web page. I wanted to get one of the many projects on my list started. I got my Pi 3 B+ and look at my list of projects. From simple local hosted web server to server up recourses I or my family might need while out and about to a home media server or home automation. Reading thru I decided on a recent project added to this list. A Steem group bot for Discord. Ya, ya, I know what your thinking "There's a hundred steem bots out there", but I really don't want this bot to run for the same old same that every other bot does. I'll get into the features more later. Being the self loathing person I am, I thought to my self "You know what might be fun! Lets write this bot in a language i've never done before". So that is what I am doing. Lets set some rules and guidlines.
- Choose a programing lang never used
- Something that can run on the Pi and be automated
- Program this bot to be open source and public by the end of project
- If you really like to punish your self write web interface for the bot
- optional: try not to cry
So you have a few choices when writing a Discord bot. There are API's for your most common lang. Checking out some of the diffrent API's I decided there was one common theme among the list of languages to choose from...
Kool kids code in python
So I headed over to python.org, Clicked on Tutorial and started reading.
Realizing quickly that I need to make some desisions on what function my bot should have I head over to discords developer portal and install their API. Discord them selfs do not make a python API but they link to a few 3rd party API. py -3 -m pip install -U discord.py
Now were rolling. Lets get this thing started...
Or so you imagine when someone is programing. Reality is there is a LOT of reading and searching google for functions and how to do simple things. Sweet, got my bot to connect and to send a message when connecting (There was a lot more time and reading between the start and here). I get to a point where I feel like im picking up steem ... dun-dun-tiss. I have my bot connecting, simple commands working and im forming a good idea of what function I should be able to do with this. Time to start intergrating with steem. So I decide I want to pull a post from a group feed, I go with a group I help admin @chronik-n-coffee, selfless promotion included. I think to my self "Hey steem is full of people that are crafty and I could use there API to do this super easy". Install steem API. Read thru the Docs... What in the shit! The offical API doesn't allow me to interact with post? At least this is the answer I get on the SteemDev Discord. Sweet jesus, I'm going to have to write my own functions to do this ... YAY, more punishment! Long story short I write a scrape (google: how to scrape with python) and get this going. Getting to a point where my bot replys to a command !!post with a embed message with the title,image, description / link to the most recent post found on group page. "Feeling good!" I'm getting some info from the Discord.py help channel on their server just to find out that im using an old version of Discord.py. I now have to migrate all of my code to the new format and this comes down to rewriting most of the code. At this point bot is running and sending post info and a few simple functions. At this point I have most of a feature list.
- Welcome Members on join
- Fun ping command
- New Post command
- Kick / ban command
Functions im working on
- Auto post new post on group page
- Group vote: Daily group account will upvote on winning post of the day
- Accept steem donation to help increase out upvote power
- Check your steem wallet
- Check user history*
Hey if you stuck in till now thank you. I know this was a long post. I will update with more post as the bot gets more offical and code gets cleaned up a bit. I'm always willing to collaberate with another programer or take help if you would like to. Thank you to @Chronik-n-coffee for letting me test the bot on the Discord. If you want to learn to code in python I've linked some recourses for a more offical approch of learning below.
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
see also: http://www.codeabbey.com/ (exercises for beginners)
You are awesome for what you are doing to help create a deeper experience for the community. Thank you brother! RESPECT
Congratulations! This post has been upvoted from the communal account, @minnowsupport, by 2toetommy from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.
If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.