Git Product home page Git Product logo

memebot's Introduction

Meme bot

Meme bot @tendTo_bot is a Telegram meme bot

Using the live version

The bot is live on Telegram with the username @tendTo_bot. To see the posts, once published, check Meme channel di meme_bot Send '/start' to start it, '/help' to see a list of commands. Please note that the commands and their answers are in Italian.

Table of contents


πŸ”§ Setting up a local istance

System requirements

Install with pip3

Listed in requirements.txt

Steps:

  • Clone this repository
  • Rename "data/db/sqlite.db.dist" in "data/db/sqlite.db"
  • Rename "config/settings.yaml.dist" in "config/settings.yaml" and edit the desired parameters:
data:
  db_url: url of your postgres database (false recommended for local)
  remote: whether the data will be saved remotely (postgres) or locally (mysql)

debug:
  db_log: save each and every message in a log file. Make sure the path "logs/messages.log" is valid before putting it to 1
  local_log: /

meme:
  channel_group_id: id of the group associated with the channel. Needed if comments are enabled
  channel_id: id of the channel to which the bot will send the approved memes
  comments: whether or not the channel the bot will send the memes to has comments enabled
  group_id: id of the admin group the memebot will use
  n_votes: votes needed to approve/reject a pending post
  reset_on_load: whether or not the database should reset every time the bot launches. USE CAREFULLY

test:
  api_hash: hash of the telegram app used for testing
  api_id: id of the telegram app used for testing
  remote:  whether you want to test the remote database, the local one or both
  session: session of the telegram app used for testing
  tag: tag of the telegram bot used for testing. Include the '@' character
  token: token for the telegram bot used for testing

token: the token for your telegram bot

webhook:
  enabled: whether or not the bot should use webhook (false recommended for local)
  url: the url used by the webhook
  • Run python3 main.py

🐳 Setting up a Docker container

System requirements

  • Docker

Steps:

  • Clone this repository
  • In "config/settings.yaml.dist", edit the desired values. Be mindful that the one listed below will overwrite the ones in "config/settings.yaml.dist", even if they aren't used in the command line
  • Run docker build --tag botimage --build-arg TOKEN=<token_arg> [...] .
In the command line
(after each --build-arg)
Type Function Optional
TOKEN=<token_args> string the token for your telegram bot REQUIRED
WEB_URL=<web_url> string the url used by the webhook REQUIRED
DATABASE_URL=<db_url> string url of your postgres database REQUIRED
GROUP_ID=<group_id> int id of the admin group the memebot will use REQUIRED
CHANNEL_ID=<channel_id> int id of the channel to which the bot will send the approved memes REQUIRED
CHANNEL_GROUP_ID=<channel_id> int id of the group associated with the channel REQUIRED IF
comments = true
  • Run docker run -d --name botcontainer botimage

To stop/remove the container:

  • Run docker stop botcontainer to stop the container
  • Run docker rm -f botcontainer to remove the container

πŸ“Š [Optional] Setting up testing

Create a Telegram app:

Steps:

  • Sign in your Telegram account with your phone number here. Then choose β€œAPI development tools”
  • If it is your first time doing so, it will ask you for an app name and a short name, you can change both of them later if you need to. Submit the form when you have completed it
  • You will then see the api_id and api_hash for your app. These are unique to your app, and not revocable.
  • Put those values in the conf/settings.yaml file for local or in the conf/settings.yaml.dist file if you are setting up a docker container
test:
    api_hash: HERE
    api_id: HERE
...
  • Copy the file tests/conftest.py in the root folder and Run python3 conftest.py . Follow the procedure and copy the session string it provides in the settings file:
test:
...
    session: HERE
...
  • You can then delete the conftest.py file present in the root folder, you won't need it again
  • Edit the remaining values in the file as you see fit

Check here you you want to have more information on the steps above

In local:

Install with pip3

Steps:

  • Run pytest

In a docker container:

Steps:

  • Add telethon, pytest and pytest-asyncio to the requirements.txt file
  • Access the container and Run pytest or edit the Dockerfile to do so

πŸ“š Documentation

Check the gh-pages branch

Link to the documentation

πŸ”€ About Pull Requests

Upon submitting a Pull Request, a github action will be triggered. The workflow will run all the tests to make sure everything still works correctly

The workflow will fail if your repository lacks even one of the following secrets:

SECRET Type Function
API_ID int id of the telegram app used for testing
API_HASH string hash of the telegram app used for testing
SESSION string session of the telegram app used for testing
TEST_TAG string tag of the bot used for testing
TEST_TOKEN string token for the bot used for testing

To pass the workflow is not mandatory, but is highly suggested

πŸ’­ Inspired by

Telegram-SpottedDMI-Bot

βš–οΈ License

MIT

memebot's People

Contributors

tendto avatar

Stargazers

 avatar

Watchers

 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.