Code Monkey home page Code Monkey logo

telegram-media-bot's Introduction

Telegram Media Bot

General

Posts images, videos and GIFs (soundless MP4s) to a specific Telegram chat from Twitter and Reddit.

Functionality

Images and most of the videos/GIFs are shown/played inline in the chats.
The source links are the caption of the medias. All sent links are saved in a file and every new media is checked if it was posted before (earlier runs, not actual one) and skips the file if it was posted.
You can set two Twitter accounts and two sets of Subreddits to define which to post. "one" or "two" as command line parameter.

Twitter

Creates the twitter-files and saves the IDs of the last posts of all your following accounts. On next run all the new posts since the saved IDs are posted and saves again the IDs of the last posts.

Reddit

Posts from all subreddits the hottest links. Gfycat and imgur links are tried to send as file for inline playback. Every Subreddit has his own configurable limit.

Installation

  • Do a virtualenv before
  • git clone https://github.com/Nama/telegram-media-bot
  • source into your virtualenv
  • cd telegram-media-bot
  • pip install -r requirements.txt
  • python setup.py install
  • telegram-media-bot.py
  • Get the example config and set it to your needs

Note
Not using Praw v4 since it forces me to use the closed API of Reddit.

Usage

Storing four files permantly, choose the working directory wisely!

  • telegram-media-bot.py twitter
    • Will save Twitter data for first use
    • Executing again, will overwrite and you will miss the Twitter posts since last runtime of the script
  • telegram-media-bot.py one
    • Will post media from Twitter account_one
    • Will post media from subs_one
  • telegram-media-bot.py two
    • Will post media from Twitter account_two
    • Will post media from subs_two
  • You can't use "one" and "two" at the same time

Cron

0 * * * * cd /home/bot/telegram-media-bot && /home/bot/venv/telegram-bot/bin/telegram-media-bot.py one
5 23 * * * cd /home/bot/telegram-media-bot && /home/bot/venv/telegram-bot/bin/telegram-media-bot.py two
  • Make sure to set a working directory
  • Choose the installed "binary" from your virtualenv
  • "one" and "two" can be posted independant from each other with other sources (Twitter accounts and Subreddits)

telegram-media-bot's People

Contributors

nama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.