Telegram Bot based on Markovify
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.dockerignore
.gitignore
Dockerfile
LICENSE
README.md
abstract_bot.py
bot_friend.py
docker-compose.yml
dropbox_text_provider.py
markovify_provider.py
meme_provider.py
telegram_client.py

README.md

TelegramBotFriend

Telegram Bot based on Markovify

Prerequisites

Setup Telegram bot.

You need to setup a bot in Telegram. You can follow this tutorial and make sure that Privacy mode is disabled you can read more about it here

Download NLTK in your language

TelegramBotFriend uses nltk in order to detect stop words. Follow nltk instructions to download the stop words for the language you're going to use.

The most important piece: Content

You can download your chat history using this extension. You could use any other source, e.g. you could download this Die Hard script and invite Bruce Willis to your group.

After picking your source text you might need to process it, e.g. You might need to remove urls from your history, or special characters.

Dropbox API

In order to make the bot easy to install in a docker container, the data source and the meme list file will be fetched from a Dropbox folder, so the bot and feed that file with new data and you don't have to think about the container storage.

So you will need to create a new dropbox token and set that token as an argument.

Usage

python bot_friend.py -t "[telegram bot token]" -l "[language]" -n "[boot name]" -d "[dropbox token]" -f "[data source file]" -m "[meme list file]" -a [1|0]
  • -t --token: It's the Telegram token BotFather provided when the bot was created
  • -l --language: Language used by NLTK to detect stop words
  • -n --name: Trigger name. TelegramBotFriend will send a message when that name is mentioned in any message
  • -d --dropboxtoken: Dropbox Token where the Source file is located
  • -f --dropboxfile: Data source file with the chat history
  • -m --memefile: Comma separated file with the meme list, expressed as "trigger word,meme url"
  • -a --autofeed: If 1 the bot will feed the chat source with new incoming messages
  • -e --joinevery: Sets how many messages the bot should wait before stepping into the conversation. It will join after a random number of messages between joinevery and joinevery * 2

Docker install

The bot can be installed in a docker container using the docker-compose.yml file as a template