Skip to content

Commit

Permalink
treewide: new config file
Browse files Browse the repository at this point in the history
  • Loading branch information
alissonlauffer committed Apr 25, 2022
1 parent 634a18f commit ae0517b
Show file tree
Hide file tree
Showing 39 changed files with 158 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Set up configuration
run: |
curl https://pastebin.com/raw/MQVHHXfn -o eduu/config.py
curl https://pastebin.com/raw/iu4nu94C -o eduu/config.py
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
Expand Down
8 changes: 4 additions & 4 deletions eduu/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pyrogram.errors import BadRequest

import eduu
from eduu.config import API_HASH, API_ID, TOKEN, disabled_plugins, log_chat
from eduu.config import API_HASH, API_ID, DISABLED_PLUGINS, LOG_CHAT, TOKEN, WORKERS
from eduu.utils import del_restarted, get_restarted, shell_exec

try:
Expand All @@ -32,9 +32,9 @@ async def main() -> None:
api_id=API_ID,
api_hash=API_HASH,
bot_token=TOKEN,
workers=24,
workers=WORKERS,
parse_mode=ParseMode.HTML,
plugins=dict(root="eduu.plugins", exclude=disabled_plugins),
plugins=dict(root="eduu.plugins", exclude=DISABLED_PLUGINS),
)

await client.start()
Expand All @@ -56,7 +56,7 @@ async def main() -> None:
)

try:
await client.send_message(chat_id=log_chat, text=start_message)
await client.send_message(chat_id=LOG_CHAT, text=start_message)
if wr:
await client.edit_message_text(wr[0], wr[1], "Restarted successfully!")
except BadRequest:
Expand Down
56 changes: 39 additions & 17 deletions eduu/config.py.example
Original file line number Diff line number Diff line change
@@ -1,30 +1,52 @@
from typing import List, Optional
from typing import List
import os.path

# This is a template configuration file for EduuRobot.
# You can use this file as a base for your own config file by
# copying this file to `eduu/config.py` and filling in the values.
#


# API keys

# Bot token from Bot Father
TOKEN: str = "YOUR_TOKEN_HERE"
TOKEN: str = "123123:YOUR_BOT_TOKEN_HERE"

# Your API ID and API HASH
# Telegram API ID and API hash
# Get it from https://my.telegram.org/apps
API_ID: int = 123123
API_HASH: str = ""
API_ID: int = 321321
API_HASH: str = "YOUR_API_HASH_HERE"

# Tenor API key
# Get it from https://tenor.com/developer/keyregistration
# Can be empty (but the /gif command won't work without it)
TENOR_API_KEY: str = ""


# Chat used for logs
log_chat: int = 123456789
# Admins/sudoers settings

# Sudoers and super sudoers
super_sudoers: List[int] = [123456789]
sudoers: List[int] = [987654321]
SUPER_SUDOERS: List[int] = [123456789]
SUDOERS: List[int] = [987654321]

# All super sudoers should be sudoers as well
SUDOERS.extend(SUPER_SUDOERS)


# Other settings

# Database file path
DATABASE_PATH = os.path.join("eduu", "database", "eduu.db")

# Number of updates that can be processed in parallel
WORKERS = 24

# Chat used for logging
LOG_CHAT: int = 123456789

# Prefixes for commands
# e.g: /command and !command
prefix: List[str] = ["/", "!"]
PREFIXES: List[str] = ["/", "!"]

# List of disabled plugins
disabled_plugins: List[str] = []

# API Keys (Optional)
TENOR_API_KEY: Optional[str] = ""

# All super sudoers should be sudoers as well
sudoers.extend(super_sudoers)
DISABLED_PLUGINS: List[str] = []
4 changes: 3 additions & 1 deletion eduu/database/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

import sqlite3

db = sqlite3.connect("eduu/database/eduu.db")
from eduu.config import DATABASE_PATH

db = sqlite3.connect(DATABASE_PATH)
dbc = db.cursor()


Expand Down
10 changes: 5 additions & 5 deletions eduu/plugins/admins/bans.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyrogram import Client, filters
from pyrogram.types import Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.utils import (
commands,
get_reason_text,
Expand All @@ -13,7 +13,7 @@
from eduu.utils.localization import use_chat_lang


@Client.on_message(filters.command("ban", prefix))
@Client.on_message(filters.command("ban", PREFIXES))
@use_chat_lang()
@require_admin(permissions=["can_restrict_members"])
async def ban(c: Client, m: Message, strings):
Expand All @@ -36,7 +36,7 @@ async def ban(c: Client, m: Message, strings):
await m.reply_text(strings("i_cant_ban_admins"))


@Client.on_message(filters.command("kick", prefix))
@Client.on_message(filters.command("kick", PREFIXES))
@use_chat_lang()
@require_admin(permissions=["can_restrict_members"])
async def kick(c: Client, m: Message, strings):
Expand All @@ -60,7 +60,7 @@ async def kick(c: Client, m: Message, strings):
await m.reply_text(strings("i_cant_kick_admins"))


@Client.on_message(filters.command("unban", prefix))
@Client.on_message(filters.command("unban", PREFIXES))
@use_chat_lang()
@require_admin(permissions=["can_restrict_members"])
async def unban(c: Client, m: Message, strings):
Expand All @@ -79,7 +79,7 @@ async def unban(c: Client, m: Message, strings):
await m.reply_text(text)


@Client.on_message(filters.command("tban", prefix))
@Client.on_message(filters.command("tban", PREFIXES))
@use_chat_lang()
@require_admin(permissions=["can_restrict_members"])
async def tban(c: Client, m: Message, strings):
Expand Down
6 changes: 3 additions & 3 deletions eduu/plugins/admins/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pyrogram import Client, filters
from pyrogram.types import Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.database import db, dbc
from eduu.utils import commands, require_admin
from eduu.utils.localization import use_chat_lang
Expand All @@ -26,7 +26,7 @@ def toggle_del_service(chat_id: int, mode: Optional[bool]):
db.commit()


@Client.on_message(filters.command("purge", prefix))
@Client.on_message(filters.command("purge", PREFIXES))
@require_admin(permissions=["can_delete_messages"], allow_in_private=True)
@use_chat_lang()
async def purge(c: Client, m: Message, strings):
Expand All @@ -52,7 +52,7 @@ async def purge(c: Client, m: Message, strings):
await status_message.delete()


@Client.on_message(filters.command("cleanservice", prefix))
@Client.on_message(filters.command("cleanservice", PREFIXES))
@require_admin(permissions=["can_delete_messages"])
@use_chat_lang()
async def delservice(c: Client, m: Message, strings):
Expand Down
8 changes: 4 additions & 4 deletions eduu/plugins/admins/mutes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyrogram import Client, filters
from pyrogram.types import ChatPermissions, Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.utils import (
commands,
get_reason_text,
Expand All @@ -13,7 +13,7 @@
from eduu.utils.localization import use_chat_lang


@Client.on_message(filters.command("mute", prefix))
@Client.on_message(filters.command("mute", PREFIXES))
@use_chat_lang()
@require_admin(permissions=["can_restrict_members"])
async def mute(c: Client, m: Message, strings):
Expand All @@ -38,7 +38,7 @@ async def mute(c: Client, m: Message, strings):
await m.reply_text(strings("i_cant_mute_admins"))


@Client.on_message(filters.command("unmute", prefix))
@Client.on_message(filters.command("unmute", PREFIXES))
@use_chat_lang()
@require_admin(permissions=["can_restrict_members"])
async def unmute(c: Client, m: Message, strings):
Expand All @@ -57,7 +57,7 @@ async def unmute(c: Client, m: Message, strings):
await m.reply_text(text)


@Client.on_message(filters.command("tmute", prefix))
@Client.on_message(filters.command("tmute", PREFIXES))
@use_chat_lang()
@require_admin(permissions=["can_restrict_members"])
async def tmute(c: Client, m: Message, strings):
Expand Down
10 changes: 5 additions & 5 deletions eduu/plugins/admins/pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pyrogram import Client, filters
from pyrogram.types import Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.database import db, dbc
from eduu.utils import commands, require_admin
from eduu.utils.localization import use_chat_lang
Expand All @@ -22,7 +22,7 @@ def toggle_antichannelpin(chat_id: int, mode: Optional[bool]):
db.commit()


@Client.on_message(filters.command("antichannelpin", prefix))
@Client.on_message(filters.command("antichannelpin", PREFIXES))
@require_admin(permissions=["can_pin_messages"])
@use_chat_lang()
async def setantichannelpin(c: Client, m: Message, strings):
Expand Down Expand Up @@ -53,7 +53,7 @@ async def acp_action(c: Client, m: Message):
pass


@Client.on_message(filters.command("pin", prefix))
@Client.on_message(filters.command("pin", PREFIXES))
@require_admin(permissions=["can_pin_messages"], allow_in_private=True)
async def pin(c: Client, m: Message):
disable_notifications = "loud" not in m.text
Expand All @@ -66,13 +66,13 @@ async def pin(c: Client, m: Message):
)


@Client.on_message(filters.command("unpin", prefix))
@Client.on_message(filters.command("unpin", PREFIXES))
@require_admin(permissions=["can_pin_messages"], allow_in_private=True)
async def unpin(c: Client, m: Message):
await c.unpin_chat_message(m.chat.id, m.reply_to_message.id)


@Client.on_message(filters.command(["unpinall", "unpin all"], prefix))
@Client.on_message(filters.command(["unpinall", "unpin all"], PREFIXES))
@require_admin(permissions=["can_pin_messages"], allow_in_private=True)
async def unpinall(c: Client, m: Message):
await c.unpin_all_chat_messages(m.chat.id)
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/cats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from pyrogram import Client, filters
from pyrogram.types import Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang


@Client.on_message(filters.command("cat", prefix))
@Client.on_message(filters.command("cat", PREFIXES))
@use_chat_lang()
async def cat(c: Client, m: Message, strings):
r = await http.get("https://api.thecatapi.com/v1/images/search")
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/coub.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from pyrogram import Client, filters
from pyrogram.types import Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang


@Client.on_message(filters.command("coub", prefix))
@Client.on_message(filters.command("coub", PREFIXES))
@use_chat_lang()
async def coub(c: Client, m: Message, strings):
if len(m.command) == 1:
Expand Down
8 changes: 4 additions & 4 deletions eduu/plugins/custom_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pyrogram.enums import ParseMode
from pyrogram.types import InlineKeyboardMarkup, Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.database import db, dbc
from eduu.utils import button_parser, commands, require_admin, split_quotes
from eduu.utils.localization import use_chat_lang
Expand Down Expand Up @@ -64,7 +64,7 @@ def check_for_filters(chat_id, trigger):
return False


@Client.on_message(filters.command(["filter", "savefilter"], prefix))
@Client.on_message(filters.command(["filter", "savefilter"], PREFIXES))
@require_admin(allow_in_private=True)
@use_chat_lang()
async def save_filter(c: Client, m: Message, strings):
Expand Down Expand Up @@ -136,7 +136,7 @@ async def save_filter(c: Client, m: Message, strings):
)


@Client.on_message(filters.command(["delfilter", "rmfilter", "stop"], prefix))
@Client.on_message(filters.command(["delfilter", "rmfilter", "stop"], PREFIXES))
@require_admin(allow_in_private=True)
@use_chat_lang()
async def delete_filter(c: Client, m: Message, strings):
Expand All @@ -155,7 +155,7 @@ async def delete_filter(c: Client, m: Message, strings):
)


@Client.on_message(filters.command("filters", prefix))
@Client.on_message(filters.command("filters", PREFIXES))
@use_chat_lang()
async def get_all_filter(c: Client, m: Message, strings):
chat_id = m.chat.id
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from pyrogram import Client, filters
from pyrogram.types import Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.utils import commands
from eduu.utils.localization import use_chat_lang


@Client.on_message(filters.command(["dice", "dados"], prefix))
@Client.on_message(filters.command(["dice", "dados"], PREFIXES))
@use_chat_lang()
async def dice(c: Client, m: Message, strings):
dicen = await c.send_dice(m.chat.id, reply_to_message_id=m.id)
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/dogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from pyrogram import Client, filters
from pyrogram.types import Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang


@Client.on_message(filters.command("dog", prefix))
@Client.on_message(filters.command("dog", PREFIXES))
@use_chat_lang()
async def dog(c: Client, m: Message, strings):
r = await http.get("https://random.dog/woof.json")
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pyrogram import Client, filters
from pyrogram.types import Message

from eduu.config import TENOR_API_KEY, prefix
from eduu.config import PREFIXES, TENOR_API_KEY
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang

Expand All @@ -16,7 +16,7 @@
)


@Client.on_message(filters.command("gif", prefix))
@Client.on_message(filters.command("gif", PREFIXES))
@use_chat_lang()
async def gif(c: Client, m: Message, strings):
if len(m.command) == 1:
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from pyrogram import Client, filters
from pyrogram.types import Message

from eduu.config import prefix
from eduu.config import PREFIXES
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang


@Client.on_message(filters.command("git", prefix))
@Client.on_message(filters.command("git", PREFIXES))
@use_chat_lang()
async def git(c: Client, m: Message, strings):
if len(m.command) == 1:
Expand Down

0 comments on commit ae0517b

Please sign in to comment.