/JoJo-Telegram-Bot

A Telegram Bot to make JoJo references!

Primary LanguagePythonMIT LicenseMIT

Telegram JoJo Bot

A bot to make JoJo references on Telegram! Try it (It might be offline)

Description

This repo contains files the JoJo bot uses to respond to messages. It is done entirely in Python3, using the requests module. Try the bot at this link, it will not reply if it's offline.

Features

  • Replies with JoJo dialogues. Use /help to see the list of supported commands and messages.
  • Can be used a JoJo soundboard! Tag the bot @oh_youre_approaching_me_bot in any chat and search for sounds.
  • /jmeme or /meme gives a random post from the r/ShitPostCrusaders subreddit. Add the bot to a group for more fun! (the bot cannot read any group messages unless you tag it or reply to it)

Requirements

These are the requirements to run the bot yourself, if you only want to interact with it use this link.

  • Python 3
  • See requirements.txt for other (python) requirements.
  • A Telegram Bot token. Learn more Telegram Bots here
  • (Optional: required for reddit memes support) A reddit dev app - note the client ID and secret there, it is needed to authenticate the bot. Refer this for creating a new reddit app.

Usage

Instructions to run the bot yourself, if you only want to interact with it use this link.

  • Create a .env file in the same directory.

  • Add your Bot Token to the .env file in this format

    TOKEN=<your bot token here>
    CLIENT_ID=<reddit api client ID here>
    CLIENT_SERVER=<reddit api client server here>
    USER_AGENT=<a custom user agent for your bot>
    
  • Run reply.py using python reply.py or python3 reply.py. This script runs infinitely and responds to messages.

reply.py

This script performs long-polling on the getUpdates method of the Telegram Bot API. As soon as a message is received, it looks for that message in message_responses dictionary and sends the corresponding response if it exists or sends a default message if it doesn't. The script also saves the last update ID it processed to a file, this update ID is sent to the API to get only new updates (this is to prevent duplicate responses).