A Twitter bot developed in Python using the Tweepy library and hosted in AWS.

Overview

Twitter Cameroon: @atangana_aron

A Twitter bot developed in Python using the Tweepy library and hosted in AWS. https://twitter.com/atangana_aron

Cost = Free!

The Bot

Yaounde (Image)

This bot will get a large sample of tweets with the word Yaoundé and then retweet the most liked tweet from the sample with an attached photo. (At present this runs only on Sundays)

Paul Biya Alert

This bot will run daily and check to see if there is an abnormally large number of relevant Tweets and then retweet the most liked tweet (if there are a lot of Tweets that day). The bot will specifically pull tweets with the word Biya and see how many of them also contain Paul.

Top 10 Words

This bot will pull a large sample of tweets with the word Cameroun (French spelling of Cameroon). For each Tweet, it removes stopwords and duplicates, then creates a bag of words counting occurrence of each word. The top 10 words are then tweeted. (At present, this runs every day except Sunday)

AWS Hosting

AWS Lambda

Lambda functions have many uses. In this case, we will use it for ultra cheap (free) hosting/computing. All work necessary in AWS to run this bot is done by navigating to Lambda in the AWS UI and creating a new function. The equivalent of main.py for a lambda function is lambda_function.py. To observe the code, start with lambda_function.py and trace its references.

Non-native Python Packages w/ Lambda

The bot relies on a non-native package (in this case Tweepy). Running the code on Lambda requires also uploading the package. This can be done in several ways, as outlined here: https://docs.aws.amazon.com/lambda/latest/dg/python-package.html

Cloudwatch Events

These are the triggers that will determine when to run your lambda function. Using cron expressions, you can set this on a schedule to run at a certain time per day, day per week/month.

Twitter API

Developer API

https://developer.twitter.com/en/docs/twitter-api

Tweepy

https://www.tweepy.org/

A few highlights:

  • Max # of tweets pulled at once is 3200
  • Can both download tweets and create tweets

Running this code

API Keys

Requires your own APIKeys.py in the API folder. Generate these from the Twitter Developer API. After signing up for a developer account, create a new project and generate read/write keys. Format of APIKeys.py should be as follows:

  • Key = 'xxx'
  • Secret = 'yyy'
  • Bearer_Token = 'zzz'
  • Access_Token = '111'
  • Access_Secret = '222'

AWS

Everything in this code runs using the free tiers of AWS. You'll need to create your own account which requires attaching a valid credit card. You'll need to create the lambda function, upload the code as a zip, attach the trigger (Cloudwatch Event), and change the runtime to allow for ~30 seconds or less. You'll need to follow the instructions under the AWS Hosting section of this readme to upload the script with the necessary package, otherwise you'll receive an error stating Tweepy: no such module.

Cost

Twitter's API has a limit of number of tweets per month (using the free version). At the time of this writing, that limit is >150x the Tweepy API call limit.

AWS Lambda has a monthly compute free tier. Each run of a bot is <.1% of that limit at the time of this writing.

You might also like...
Fetch the details of assets hosted on AWS.
Fetch the details of assets hosted on AWS.

onaws onaws is a simple tool to check if an IP/hostname belongs to the AWS IP space or not. It uses the AWS IP address ranges data published by AWS to

This is a telegram bot hosted by a Raspberry Pi equipped with a temperature and humidity sensor. The bot is capable of sending plots and readings.
This is a telegram bot hosted by a Raspberry Pi equipped with a temperature and humidity sensor. The bot is capable of sending plots and readings.

raspy-temperature-bot This is a telegram bot hosted by a Raspberry Pi equipped with a temperature and humidity sensor. The bot is capable of sending p

Actively maintained, pure Python wrapper for the Twitter API. Supports both normal and streaming Twitter APIs.

Twython Twython is a Python library providing an easy way to access Twitter data. Supports Python 3. It's been battle tested by companies, educational

Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the pointless 3200 tweet limit imposed by Twitter.
Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the pointless 3200 tweet limit imposed by Twitter.

Twitter Nuke Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the puny and pointl

Project template for using aws-cdk, Chalice and React in concert, including RDS Postgresql and AWS Cognito

What is This? This repository is an opinonated project template for using aws-cdk, Chalice and React in concert. Where aws-cdk and Chalice are in Pyth

A twitter multi-tool for OSINT on twitter accounts.

TwitterCheckr A twitter multi-tool for OSINT on twitter accounts. Infomation TwitterCheckr also known as TCheckr is multi-tool for OSINT on twitter a

Twitter-redesign - Twitter Redesign With Django

Twitter Redesign A project that tests Django and React knowledge through a twitt

AWS Blog post code for running feature-extraction on images using AWS Batch and Cloud Development Kit (CDK).

Batch processing with AWS Batch and CDK Welcome This repository demostrates provisioning the necessary infrastructure for running a job on AWS Batch u

(@Tablada32BOT is my bot in twitter) This is a simple bot, its main and only function is to reply to tweets where they mention their bot with their @

Remember If you are going to host your twitter bot on a page where they can read your code, I recommend that you create an .env file and put your twit

Owner
master's student in data science at Georgia Tech
null
twitter bot tha uses tweepy library class to connect to TWITTER API

TWITTER-BOT-tweepy- twitter bot that uses tweepy library class to connect to TWITTER API replies to mentions automatically and follows the tweet.autho

Muziwandile Nkomo 2 Jan 8, 2022
An automated bot for twitter using Tweepy!

Tweeby An automated bot for twitter using Tweepy! About This bot will look for tweets that contain certain hashtags, if found. It'll send them a messa

Ori 1 Dec 6, 2021
Automatically updates the twitter banner with the images of 5 latest followers, using tweepy python

Auto twitter banner Automatically updates the twitter banner every few seconds with follower profile pics on it Here's how it looks! Installation git

Dhravya Shah 7 Jul 4, 2022
DIAL(Did I Alert Lambda?) is a centralised security misconfiguration detection framework which completely runs on AWS Managed services like AWS API Gateway, AWS Event Bridge & AWS Lambda

DIAL(Did I Alert Lambda?) is a centralised security misconfiguration detection framework which completely runs on AWS Managed services like AWS API Gateway, AWS Event Bridge & AWS Lambda

CRED 71 Dec 29, 2022
A Phyton script working for stream twits from twitter by tweepy to mongoDB

twitter-to-mongo A python script that uses the Tweepy library to pull Tweets with specific keywords from Twitter's Streaming API, and then stores the

null 3 Feb 3, 2022
Implement backup and recovery with AWS Backup across your AWS Organizations using a CI/CD pipeline (AWS CodePipeline).

Backup and Recovery with AWS Backup This repository provides you with a management and deployment solution for implementing Backup and Recovery with A

AWS Samples 8 Nov 22, 2022
Twitter-bot - A Simple Twitter bot with python

twitterbot To use this bot, You will require API Key and Access Key. Signup at h

Bentil Shadrack 8 Nov 18, 2022
Automated AWS account hardening with AWS Control Tower and AWS Step Functions

Automate activities in Control Tower provisioned AWS accounts Table of contents Introduction Architecture Prerequisites Tools and services Usage Clean

AWS Samples 20 Dec 7, 2022
Twitter bot that finds new friends in Twitter.

PythonTwitterBot Twitter Bot Thats Find New Friends pip install textblob pip install tweepy pip install googletrans check requirements.txt file Env

IbukiYoshida 4 Aug 11, 2021