Skip to content

Instantly share code, notes, and snippets.

@eimon96
Last active April 29, 2022 09:29
Show Gist options
  • Save eimon96/9000ebf2b9037441f847b054b61e1a28 to your computer and use it in GitHub Desktop.
Save eimon96/9000ebf2b9037441f847b054b61e1a28 to your computer and use it in GitHub Desktop.
A simple Twitter bot, build with Tweepy - created 2/2021 - revisited 4/2022 ... #procrastinator

My little Twitter Bot build with Tweepy 4.8.0 in Python 3.9.2

DISCLAIMER: This project is made for educational purposes as well as for fun. I dont mean to harm or offend anyone. ❤️


Setup:

(Debian Kernel Shell)

$ mkdir my_botaki
$ cd my_botaki
$ python3 -m venv venv
$ source ./venv/bin/activate
$ pip install tweepy
$ pip freeze > requirements.txt

A developer account on twitter required.

python3 botaki8rc.py

(add credentials into the code first :P)

Boom! Bot comes to life.


Bot example: eimon8rc

import tweepy
import datetime
import time
import random
def main():
# Authenticate to Twitter
CONSUMER_KEY = ""#add
CONSUMER_SECRET = ""#add
ACCESS_TOKEN = ""#add
ACCESS_TOKEN_SECRET = ""#add
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
try:
api.verify_credentials()
print("Authentication OK!")
except Exception as e:
print("Error during authentication..")
raise e
#comment_string(api, "Hello World!")
#comment_date_time(api)
#read_tweets(api)
#print_info_about_user(api)
#follow_sb(api)
#change_description(api)
sing(api)
def comment_date_time(api):
dt = datetime.datetime.now()
api.update_status(f"Whatever, {dt}")
def comment_string(api, str):
api.update_status(str)
# reads tweets from home page
def read_tweets(api):
timeline = api.home_timeline()
for tweet in timeline:
print(f"{tweet.user.name} said {tweet.text}")
# Uh <3
def print_info_about_user(api):
user = api.get_user(screen_name='Unboxholics')
print("\nUser details:\n")
print(user.name)
print(user.description)
print(user.location)
print("Last 20 Followers: \n")
for follower in user.followers():
print(follower.name)
# Uh <3<3
def follow_sb(api):
api.create_friendship(screen_name='Unboxholics')
def change_description(api):
api.update_profile(description = "I'm a bot dabadee daba da - ver2022")
# G7
def sing(api):
user = api.get_user(screen_name='')#add
rec = user.id_str
sText = ["eisai sto mualo kati magiko opou pas esy tha mai panta egw na sou tragoudw thrylole ole thrylole ole thrylole ole thrylole ole thrylole ole",
"thryle mou h zwh den kserw ti tha pei mono esena egw exw sto mualo opou paizeis esu tha mai ki egw mazi na sou tragoudw poso sagapw ooooo ooooo ooooo de fevgoume apo dw",
"xwris mualo afou to exasa ki auto me thn arrwstia pou xw ton olympiako giauto tha zw me ena oneiro trelo o thrylos na shkwsei to evrwpaiko",
"thryle ole thryle ole se vlepw kai trelainomai thryle ole thryle ole se vlepw kai trelainomai ton thrylo mou ton agapw kai panta ton akolouthw pote den prokeitai egw na ton afhsw monaxo", "pantou taksidevw xiliometra kanw ki arrwstainw kathe mera polles alhteis kai ta muala mas kokkina vammena gia esena",
"eisai h kapsoura mou megalh h mastoura mou gia sena tha pethanw egw gia sena mono zw",
"thrylole thrylole na xame enan nargile na ta vlepame ola kokkina kai aspra kai rige",
"den kserw ti einai auto pou moy sunvainei kai marrwstainei kai mou xei parei to mualo mastoura san esena den uparxei ta exw xasei paw na trelathw thryle ole ole ole oleo thryle oleo thryle ole ole ole thryle ole ole ole oleo thryle oleo thryle sagapw"]
while True:
r = random.randint(1, len(sText))
dm = api.send_direct_message(rec, sText[r - 1])
time.sleep(96) # seconds
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment