{"id":18799361,"url":"https://github.com/alkesst/pytwebot","last_synced_at":"2026-04-15T07:33:35.158Z","repository":{"id":81790415,"uuid":"99825613","full_name":"Alkesst/pytwebot","owner":"Alkesst","description":"A short twitter bot made with Python","archived":false,"fork":false,"pushed_at":"2017-10-15T18:31:50.000Z","size":651,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-31T04:10:54.326Z","etag":null,"topics":["bot","python","raspberry-pi","rpi","tweepy","twitter"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alkesst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-09T15:45:39.000Z","updated_at":"2017-12-10T22:21:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"1633f21a-7fe9-4a64-a872-d3978716b567","html_url":"https://github.com/Alkesst/pytwebot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Alkesst/pytwebot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alkesst%2Fpytwebot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alkesst%2Fpytwebot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alkesst%2Fpytwebot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alkesst%2Fpytwebot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alkesst","download_url":"https://codeload.github.com/Alkesst/pytwebot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alkesst%2Fpytwebot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31831835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T07:17:56.427Z","status":"ssl_error","status_checked_at":"2026-04-15T07:17:30.007Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","python","raspberry-pi","rpi","tweepy","twitter"],"created_at":"2024-11-07T22:15:00.013Z","updated_at":"2026-04-15T07:33:35.106Z","avatar_url":"https://github.com/Alkesst.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyTwe-Bot\n###### A Twitter bot.\n## INTRODUCTION:\n\nCurrently the bot is hosted in a Raspberry Pi 3 model b with Ubuntu 16.04.3.\n\nMade with Tweepy 3.5.0 (http://tweepy.readthedocs.io/en/v3.5.0/index.html) and Python 2.7\n\n\n\n\nClass PyTweListener: This method will stop the stream if you exceed the allowed number of connections to the twitter API.\nThe BotListener is just a class that extends from tweepy.StreamListener. The method on_status filter the tweets and checks whether it can do something with that tweet, for example, fav it or reply to it with an image. The methon on_error just ends the stream if the stream raises the error 420.\n\n```python\n    def on_error(self, status_code):\n        if status_code == 420:\n            return False\n```\n\nIn the class TwitterMethods you can find some algorithms that you can use with your authenticated twitter account.\n\nThe script tweet_current_status.py is necessary to be run it in a Raspberry Pi. The script take some info from the current status of the Rpi and tweets it to the world.\n\nThe first command executes the program /opt/vc/bin/vcgencmd with the measure_temp argument, and the output it's saved in current_temp, same with current_mem. This is useful information of the RPi's status.\n```python\n    current_temp = subprocess.check_output([\"/opt/vc/bin/vcgencmd\", \"measure_temp\"])\n    current_mem = subprocess.check_output([\"free\", \"-h\"])\n````\n\nThe special_actions.py is a class that makes special things with some python libraries. Currently just creates an image with a given text. If you want to use that class you'll need python-wand, that requieres imagemagick 6.\n\n\n```sh\n    sudo apt-get install python-wand\n```\n\nUbuntu 16.04.3 has already installed imagemagick 6.\n\n## AUTOMATE THE BOT\n\n### Script\n\nFor initializing the bot when the rpi powers on you can use a service that executes a bash script like this:\n```sh\n    cd /home/user_name/PyTwe-Bot\n    STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` \u003e /dev/null \u0026\u0026 echo ok || echo error)\n    while [  $STATE == \"error\" ]; do\n        #do a ping and check that its not a default message or change to grep for something else\n        STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` \u003e /dev/null \u0026\u0026 echo ok || echo error)\n\n        #sleep for 2 seconds and try again\n        sleep 2\n     done\n    echo \"Pulling PyTwe-Bot...\"\n    echo\n    git pull\n    echo\n    echo \"Pull done...\"\n    echo \"Initializating PyTwe-Bot...\"\n    echo nope | python stream_bot.py\n```\n\nThis check if there's internet connection, if not, wait 2 secs and retry a ping. I made this because, when the service\npowers on, executes the script and raises an error from the python code informing that there's no internet connection.\n```sh\nSTATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` \u003e /dev/null \u0026\u0026 echo ok || echo error)\nwhile [  $STATE == \"error\" ]; do\n    #do a ping and check that its not a default message or change to grep for something else\n    STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` \u003e /dev/null \u0026\u0026 echo ok || echo error)\n\n    #sleep for 2 seconds and try again\n    sleep 2\n done\n```\n\nWhen the script is executed it checks if there was any change in the code, and starts up the bot with the new changes.\n\n### Service:\nNow is needed to make the pytwe.service file:\n```\n[Unit]\nDescription=PyTwe-Bot\n\n[Service]\nExecStart=/home/pi/rpi_pytwe_script.sh\n\n[Install]\nWantedBy=multi-user.target\n```\n\nThen, is requiered to put this file into /etc/systemd/system/. The user is not allowed to move files into /etc/systemd/system. It's necessary to use this command:\n```sh\n    sudo mv pytwe.service /etc/systemd/system\n```\n\nWith this you enable the service, and will execute when the rpi powers on:\n```sh\n    sudo systemctl enable pytwe.service\n```\n\nDon't forget this:\n```sh\n    chmod a+x rpi_pytwe_script.sh\n```\n\nAnd now the script rpi_pytwe_script.sh will run always that the rpi powers on.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkesst%2Fpytwebot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falkesst%2Fpytwebot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkesst%2Fpytwebot/lists"}