Skip to content

A Telegram Bot that replaces faces in images with the face of Harambe.

Notifications You must be signed in to change notification settings

sibljon/harambify-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Harambify Telegram Bot

A Telegram Bot to remember Harambe through replacing faces with his own.

Setup

Creating a new bot in Telegram

You do this by messaging @BotFather in the Telegram app itself.

Deploying to AWS Lambda

Creating your bot's AWS Lambda function

See AWS Lambda Initial Setup

Deploying the app

  1. Zip all of the contents of this repo (READ: the contents, not a single directory containing the contents).
  2. Choose Upload a .ZIP file in the Code tab
  3. Set your Telegram bot token as an environment variable

Register your webhook with Telegram

  1. Once your Lambda function is running on AWS, switch to the Triggers tab and copy your API Gateway URL. Paste it into the following command to register it as the webhook URL to which Telegram should post:

curl -XPOST https://api.telegram.org/botYOURTOKEN/setWebhook\?url\=YOURAPIGATEWAYURL

Running Locally

macOS

TODO: add instructions to run as a simple Flask app to poll as Dogefy Telegram Bot does

Content

File/Directory Character
harambe.png Faces are replaced with this image, and alpha layers are preserved.
cascade.xml The OpenCV algorithm by which human faces are detected. This algorithm is hosted here.
lambda.py This is where the logic happens. lambda_handler() is the function that the AWS Lambda function executes when telegram POSTs to the AWS API Gateway's webhook URL.
cv2/ OpenCV wrapped in Python. Since OpenCV is native code, it is necessary to do pip install opencv-python on the environment in which it will run. The cv2 directory contained in this repo has been built by running [ip install opencv-python on an EC2 instance running Amazon Linux AMI, which is what AWS Lamba also runs. In other words, if you are running Harambify locally, you'll need to rebuild OpenCV on your machine.
telebot/ [pyTelegramBotAPI], a Telegram Bot SDK for Python. pip install pyTelegramBotAPI.
requests/ A dependency of pyTelegramBotAPI.

TODO

  • Scriptify the AWS Lambda deployment
  • Add instructions for running locally on other platforms
  • Pluralize the "1 people have honored Harambe" and perhaps pepper in some wit and rotate messages
  • Fix a bug preventing multi-face detection

Credits

The face-swap code is essentially a fork of the Dogefy Telegram Bot.

About

A Telegram Bot that replaces faces in images with the face of Harambe.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages