Coder Social home page Coder Social logo

metabutler / metabutler Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 52.0 2.78 MB

A modular telegram Python bot running on Python3 with an sqlalchemy database.

Home Page: https://t.me/metabutlerbot

License: GNU Affero General Public License v3.0

Python 99.95% Mako 0.05%
bot group-manager-bot groupmanager hacktoberfest hacktoberfest-accepted manager python-telegram-bot python3 telegram telegram-bot telegram-bot-api

metabutler's Introduction

MetaButler

A modular telegram Python bot running on python3 with an sqlalchemy database.

Originally a Kigyo fork -

Can be found on telegram as MetaButler.

The Support group can be reached out to at MetaButler, where you can ask for help setting up your bot, discover/request new features, report bugs, and stay in the loop whenever a new update is available.

Setting up the bot (Read this before trying to use!):

How to setup

  • clone this repository
  • cd MetaButler
  • cp sample_config.ini config.ini
  • Fill in all the vars
  • cp alembic_sample.ini alembic.ini
  • Fill in sqlalchemy.url var (L#55) with the same value as SQLALCHEMY_DATABASE_URI from config.ini
  • pip3 install -U -r requirements.txt
  • The following step is important, it introduces a new column to blacklist table:
  • alembic upgrade head
  • And finally python3 -m MetaButler

Enjoy!

How can I obtain bot_token?

Just talk to BotFather(described here) and follow a few simple steps. Once you've created a bot and received your authorization token, that's it! that's your bot_token.

How can I obtain a api_key and api_hash?

In order to obtain an API key and hash you need to do the following:

  • Sign up for Telegram using any application.
  • Login to your Telegram core: https://my.telegram.org.
  • Go to 'API Development tools' and fill out the form.
  • You will get basic addresses as well as the api_id and api_hash parameters required for Metabutler's configuration file.

Database

If you wish to use a database-dependent module(eg: locks, notes, userinfo, users, filters, welcomes), you'll need to have a database installed on your system. I use postgres, so I recommend using it for optimal compatibility.

In the case of postgres, this is how you would set up a the database on a debian/ubuntu system. Other distributions may vary.

  • install postgresql:

sudo apt-get update && sudo apt-get install postgresql

  • change to the postgres user:

sudo su - postgres

  • create a new database user(change YOUR_USER appropriately):

createuser -P -s -e YOUR_USER

This will be followed by you needing to input your password.

  • create a new database table:

createdb -O YOUR_USER YOUR_DB_NAME

Change YOUR_USER and YOUR_DB_NAME appropriately.

  • finally:

psql YOUR_DB_NAME -h YOUR_HOST YOUR_USER

This will allow you to connect to your database via your terminal. By default, YOUR_HOST should be 0.0.0.0:5432.

You should now be able to build your database URI. This will be:

sqldbtype://username:pw@hostname:port/db_name

Replace sqldbtype with whichever db youre using(eg postgres, mysql, sqllite, etc) repeat for your username, password, hostname(localhost?), port(5432?), and db name.

Credits

The bot is based of on the original work done by

Thanks to

metabutler's People

Contributors

1maverick1 avatar akshettrj avatar anonymousx1025 avatar architdate avatar ayrahikari avatar dank-del avatar deepsource-autofix[bot] avatar deepsourcebot avatar destroyer-32 avatar dragsama avatar fushinori avatar gotenksin avatar halodragon7410 avatar jvlianodorneles avatar neppu-nep avatar notfounderror avatar omar-abdul-azeez avatar paulsonoflars avatar sitischu avatar skittles9823 avatar soapdev2018 avatar spechide avatar sphericalkat avatar starry-shivam avatar termozour avatar the-blank-x avatar tsunayoshisawada avatar tusharsadhwani avatar vijaymalav564 avatar zekxtreme avatar

Stargazers

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

Watchers

 avatar

metabutler's Issues

Table 'db.blacklist' doesn't exist

Hi!
Looks like alembic upgrade head doesn't create tables. Should I create it manually?

sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1146, "Table 'db.blacklist' doesn't exist")
[SQL: ALTER TABLE blacklist ADD COLUMN custom_mode TEXT]

Error: 'NoneType' object has no attribute 'inline_keyboard'

Full Traceback:

Traceback (most recent call last):
  File "/home/ubuntu/.local/share/virtualenvs/MetaButler-tvO0dz19/lib/python3.10/site-packages/telegram/ext/utils/promise.py", line 96, in run
    self._result = self.pooled_function(*self.args, **self.kwargs)
  File "/home/ubuntu/MetaButler/MetaButler/modules/helper_funcs/chat_status.py", line 421, in connected_status
    return func(update, context, *args, **kwargs)
  File "/home/ubuntu/MetaButler/MetaButler/modules/log_channel.py", line 31, in log_action
    result = func(update, context, *args, **kwargs)
  File "/home/ubuntu/MetaButler/MetaButler/modules/antiflood.py", line 57, in check_flood
    is_user_admin(update, user.id)
  File "/home/ubuntu/MetaButler/MetaButler/modules/helper_funcs/chat_status.py", line 52, in is_user_admin
    msg.reply_to_message.sender_chat.type != "channel" and not re.match(r'rm_warn\((.+?)\)', msg.reply_markup.inline_keyboard[0][0].callback_data))
AttributeError: 'NoneType' object has no attribute 'inline_keyboard'

Dockerfile

i created a very simple Dockerfile for building a Docker Container

FROM python:3.10-slim-buster

WORKDIR /app

RUN apt-get update && apt-get install -y
git

COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt

COPY . .

CMD [ "python3", "-m" , "MetaButler"]

Handle welcomes & goodbyes using ChatMemberUpdated

Goal: Use ChatMemberUpdated class to handle welcoming and goodbyes in groups

Handle welcomes and goodbyes in groups using ChatMemberUpdated class. Telegram introduced ChatMemberUpdated with Bot API v5.1. Current implementation is based on Telegram sending joining and leaving updates. Since that is inefficient (leaving updates are not sent in large groups, >1000 members) and even for small groups, it is being observed that telegram is gradually stopping sending group join updates. ChatMemberUpdated is a viable replacement to the old method of relying on updates.

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.