Git Product home page Git Product logo

r2tg_bot's Introduction

r2tg_bot

A Reddit bot that uploads video or GIF files to Telegram. Just mention me (u/r2tg_bot) in the comments. All requests are upload to archive channel by default. NSFW etc. content is not allowed on default channel. If you liked me, reply to my answer saying "good bot".

Archive channel: https://t.me/s/r2tg_bot_archive

Show the demo

Features

  • Tiny and fast
  • Customizable
  • Self-hosted
  • Trigger with comment
  • Video and GIF upload
  • Written in Python

Requirements

Python: 3.6+ is required. Also it use FFmpeg to merge downloaded video and audio.

For Debian based:

apt install ffmpeg

For Arch based:

pacman -S ffmpeg4.0

Installing and Running

Clone the reporistrory:

git clone https://github.com/beucismis/r2tg_bot

Install dependencies:

pip3 install --user -r requirements.txt

Set service file (Don't forget to set the user):

cp r2tg_bot.service /etc/systemd/system/

Set configuration file (Click for more):

cd src/
cp config.ini.sample config.ini

Running the bot:

service r2tg_bot enable # or disable
service r2tg_bot start # or restart maybe stop

Chech the bot status:

service r2tg_bot status

Configuration File

General:

key type description
limit_on_inbox int The number of messages to read in the Reddit inbox.
comment_log_indent int ?
seconds_between_runs int Cycle waiting time. In seconds.
max_num_tags_per_user_in_chain int Max num tags per user in chain.
seconds_to_wait_after_rate_limiting int Seconds to wait after rate limiting.
default_telegram_channel str Channel name. Don't forget to add the bot to the channel.

Reddit:

key type description
username str Reddit acount username. E.g: u/r2tg_bot
password str Reddit acount password.
user_agent str Reddit user-agent. E.g: r2tg_bot by u/beucismis
client_id str Reddit client ID. See: https://old.reddit.com/prefs/apps/
client_secret str Reddit client secret. See: https://old.reddit.com/prefs/apps/

Telegram:

key type description
session_name str Session name. E.g: r2tg_bot
api_id str App ID. See: https://my.telegram.org/apps
api_hash str API hash. See: https://my.telegram.org/apps
bot_token str Bot token: See: https://core.telegram.org/api#bot-api

Black List:

key type description
users str Blocked users list. E.g: AutoModerator,Sub_Corrector_Bot
subrettis str Blocked subreddits list. E.g: depression,SuicideWatch

Info:

key type description
source_code str Source code URL.
about str About page URL.
feedback str Feedback page URL.

Tips and Tricks

Use tail -f src/logs/r2tg_bot.log for live log output.
Add 0 0 * * * /bin/rm -f /home/username/r2tg_bot/src/media/*.mp4 to your cron file to clean media once a day.

License

This project lisanced under GPL-3.0 - for details check LICENSE file.

r2tg_bot's People

Contributors

beucismis avatar emreada avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

r2tg_bot's Issues

Problem with calling the Telegram bot

If I use such a method, the Telegram bot won't enter the main While loop after being called.

def run_the_bot():
    bot = R2TG_BOT(get_reddit(), get_telegram())

    telegram = bot._telegram
    telegrma.run() # bot call method

    # :( 

    while True:
        try:
            bot.reply_to_username_mentions()
        except Exception as e:
            logger.error("Got an unexpected error when reading inbox: " + str(e))

        time.sleep(c.SECONDS_BETWEEN_RUNS)

go to __init__.py

I want to use Thread for this problem...

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.