diff --git a/README.md b/README.md index ec88390..a8ff703 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Modular HunterxHunter themed Telegram Bot for managing your group with additional features. -[![alluka](https://telegra.ph/file/4d3a649980e88c3eeb362.jpg)](https://telegram.dog/zoldycktmbot) +[![alluka](https://telegra.ph/file/4d3a649980e88c3eeb362.jpg)](https://heroku.com/deploy) ### Configuration diff --git a/alluka/__init__.py b/alluka/__init__.py index e29bbfa..1d54492 100644 --- a/alluka/__init__.py +++ b/alluka/__init__.py @@ -2,6 +2,7 @@ import sys import yaml import spamwatch +import os from telethon import TelegramClient import telegram.ext as tg @@ -21,6 +22,7 @@ ) quit(1) +ENV = bool(os.environ.get('ENV', True)) # Load config try: CONFIG = yaml.load(open('config.yml', 'r'), Loader=yaml.SafeLoader) @@ -36,10 +38,11 @@ if not CONFIG['alluka_explain_config'] == "alluka_zoldyck": print("Read config.yml file carefully.") quit(1) - TOKEN = CONFIG['bot_token'] API_KEY = CONFIG['api_key'] API_HASH = CONFIG['api_hash'] + + try: OWNER_ID = int(CONFIG['owner_id']) @@ -97,36 +100,94 @@ URL = CONFIG['url'] BAN_STICKER = CONFIG['ban_sticker'] -# zoldyck family -ALLUKA = CONFIG['alluka'] -HISOKA = CONFIG['hisoka'] -GING = CONFIG['ging'] -SHIZUKU = CONFIG['shizuku'] -SILVA = CONFIG['silva'] -GON = CONFIG['gon'] -ILLUMI_ZOLDYCK = CONFIG['illumi'] -LEORIO = CONFIG['leorio'] -BISCUIT = CONFIG['biscuit'] -CHROLLO = CONFIG['chrollo'] -KILLUA = CONFIG['killua'] -MERUEM = CONFIG['meruem'] -KITE = CONFIG['kite'] +ENV = bool(os.environ.get('ENV', False)) + +if ENV: + TOKEN = os.environ.get('TOKEN', None) + API_KEY = os.environ.get('API_KEY',None) + API_HASH = os.environ.get('API_HASH',None) + + try: + OWNER_ID = int(os.environ.get('OWNER_ID', None)) + except ValueError: + raise Exception("Your OWNER_ID env variable is not a valid integer.") + + MESSAGE_DUMP = os.environ.get('MESSAGE_DUMP', None) + OWNER_USERNAME = os.environ.get("OWNER_USERNAME", None) + + try: + SUDO_USERS = set(int(x) for x in os.environ.get("SUDO_USERS", "").split()) + DEV_USERS = set(int(x) for x in os.environ.get("DEV_USERS", "").split()) + except ValueError: + raise Exception("Your sudo or dev users list does not contain valid integers.") + + try: + SUPPORT_USERS = set(int(x) for x in os.environ.get("SUPPORT_USERS", "").split()) + except ValueError: + raise Exception("Your support users list does not contain valid integers.") + + try: + SPAMMERS = set(int(x) for x in os.environ.get("SPAMMERS", "").split()) + except ValueError: + raise Exception("Your spammers users list does not contain valid integers.") + + try: + WHITELIST_USERS = set(int(x) for x in os.environ.get("WHITELIST_USERS", "").split()) + except ValueError: + raise Exception("Your whitelisted users list does not contain valid integers.") + + #ZOLDYCK_FAIMLY_LIST + ALLUKA = os.environ.get('ALLUKA', None) + HISOKA = os.environ.get('HISOKA', None) + GING = os.environ.get('GING', None) + SHIZUKU = os.environ.get('SHIZUKU', None) + SILVA = os.environ.get('SILVA', None) + GON = os.environ.get('GON', None) + ILLUMI_ZOLDYCK = os.environ.get('ILLUMI_ZOLDYCK', None) + LEORIO = os.environ.get('LEORIO', None) + BISCUIT = os.environ.get('BISCUIT', None) + CHROLLO = os.environ.get('CHROLLO', None) + KILLUA = os.environ.get('KILLUA', None) + MERUEM = os.environ.get('MERUEM', None) + KITE = os.environ.get('KITE', None) + + + GBAN_LOGS = os.environ.get('GBAN_LOGS', None) + WEBHOOK = bool(os.environ.get('WEBHOOK', False)) + URL = os.environ.get('URL', "") # Does not contain token + PORT = int(os.environ.get('PORT', 5000)) + CERT_PATH = os.environ.get("CERT_PATH") + + DB_URI = os.environ.get('DATABASE_URL') + DONATION_LINK = os.environ.get('DONATION_LINK') + LOAD = os.environ.get("LOAD", "").split() + NO_LOAD = os.environ.get("NO_LOAD", "translation").split() + DEL_CMDS = bool(os.environ.get('DEL_CMDS', False)) + STRICT_GBAN = bool(os.environ.get('STRICT_GBAN', False)) + STRICT_GMUTE = bool(os.environ.get('STRICT_GMUTE', False)) + WORKERS = int(os.environ.get('WORKERS', 8)) + BAN_STICKER = os.environ.get('BAN_STICKER', 'CAACAgUAAxkBAAIHsl5nbqXdDTmpG2HFDNhnwvE5kFbWAAI9AQAC3pTNLzeTCUmnhTneGAQ') + ALLOW_EXCL = os.environ.get('ALLOW_EXCL', False) + CASH_API_KEY = os.environ.get('CASH_API_KEY', None) + TIME_API_KEY = os.environ.get('TIME_API_KEY', None) + WALL_API = os.environ.get('WALL_API',None) + LYDIA_API = os.environ.get('LYDIA_API',None) + DEEPFRY_TOKEN = os.environ.get('DEEPFRY_TOKEN',None) + sw = None + + + + SUDO_USERS.add(OWNER_ID) DEV_USERS.add(OWNER_ID) -SUDO_USERS.add(802002142) -# SpamWatch -spamwatch_api = CONFIG['sw_api'] -if spamwatch_api == "None": - sw = None - LOGGER.warning("SpamWatch API key is missing! Check your config.env.") -else: - sw = spamwatch.Client(spamwatch_api) + updater = tg.Updater(TOKEN, workers=WORKERS) dispatcher = updater.dispatcher + tbot = TelegramClient("alluka", API_KEY, API_HASH) SUDO_USERS = list(SUDO_USERS) + list(DEV_USERS) diff --git a/alluka/modules/antispam.py b/alluka/modules/antispam.py index 7e27b6e..5f81770 100644 --- a/alluka/modules/antispam.py +++ b/alluka/modules/antispam.py @@ -9,7 +9,7 @@ from telegram.utils.helpers import mention_html from alluka.modules.helper_funcs.chat_status import user_admin, is_user_admin, support_plus import alluka.modules.sql.antispam_sql as sql -from alluka import dispatcher, OWNER_ID, SUDO_USERS, DEV_USERS, SUPPORT_USERS, WHITELIST_USERS, STRICT_GBAN, GBAN_LOGS, sw +from alluka import dispatcher, OWNER_ID, SUDO_USERS, DEV_USERS, SUPPORT_USERS, WHITELIST_USERS, STRICT_GBAN, GBAN_LOGS from alluka.modules.helper_funcs.chat_status import user_admin, is_user_admin from alluka.modules.helper_funcs.extraction import extract_user, extract_user_and_text from alluka.modules.helper_funcs.filters import CustomFilters @@ -276,37 +276,16 @@ def gbanlist(bot: Bot, update: Update): update.effective_message.reply_document(document=output, filename="gbanlist.txt", caption="Here is the list of currently gbanned users.") -def check_and_ban(update, user_id, should_message=True): - chat = update.effective_chat - message = update.effective_message - if sw != None: - sw_ban = sw.get_ban(user_id) - if sw_ban: - spamwatch_reason = sw_ban.reason - chat.kick_member(user_id) - if should_message: - message.reply_text( - (chat.id, - "This user is detected as a spambot by SpamWatch and has been removed!\n\nReason: {}").format(spamwatch_reason), - parse_mode=ParseMode.HTML) - return - else: - return - if sql.is_user_gbanned(user_id): - chat.kick_member(user_id) +def check_and_ban(update, user_id, should_message=True): + spmban = spamwtc.get_ban(int(user_id)) + if spmban: + update.effective_chat.kick_member(user_id) if should_message: - userr = sql.get_gbanned_user(user_id) - usrreason = userr.reason - if not usrreason: - usrreason = (chat.id, "No reason given") - - message.reply_text(( - chat.id, "*This user is gbanned and has been removed.*\nReason: `{}`").format(usrreason), - parse_mode=ParseMode.MARKDOWN) + update.effective_message.reply_markdown("**This user is detected as potential Spambot by SpamWatch and have been removed!**\n\nPlease visit @SpamWatchSupport to know more or Appeal!") + return + else: return - - @run_async def enforce_gban(bot: Bot, update: Update): diff --git a/alluka/modules/blacklist_stickers.py b/alluka/modules/blacklist_stickers.py index f2ffd49..4c95cab 100644 --- a/alluka/modules/blacklist_stickers.py +++ b/alluka/modules/blacklist_stickers.py @@ -86,7 +86,7 @@ def add_blackliststicker(bot: Bot, update: Update): added = 0 for trigger in to_blacklist: try: - get = context.bot.getStickerSet(trigger) + get = bot.getStickerSet(trigger) sql.add_to_stickers(chat_id, trigger.lower()) added += 1 except BadRequest: diff --git a/app.json b/app.json new file mode 100644 index 0000000..f5d6f86 --- /dev/null +++ b/app.json @@ -0,0 +1,221 @@ +{ + "addons": [ + { + "options": { + "version": "9.5" + }, + "plan": "heroku-postgresql" + } + ], + "description": "Modular Telegram bot for managing your groups with a few extras features with HunterXHunter theme.", + "env": { + "ALLOW_EXCL": { + "description": "Set this to True if you want ! to be a command prefix along with /", + "value": "True" + }, + "BAN_STICKER": { + "description": "ID of the sticker you want to use when banning people.", + "required": false, + "value": "CAACAgUAAxkBAAIHsl5nbqXdDTmpG2HFDNhnwvE5kFbWAAI9AQAC3pTNLzeTCUmnhTneGAQ" + }, + "DEL_CMDS": { + "description": "Set this to True if you want to delete command messages from users who don't have the perms to run that command.", + "value": "False" + }, + "DONATION_LINK": { + "description": "Optional: link where you would like to receive donations.", + "required": false, + "value": "https://www.paypal.me/PaulSonOfLars" + }, + "ENV": { + "description": "Setting this to ANYTHING will enable environment variables.", + "value": "ANYTHING" + }, + "SQLALCHEMY_DATABASE_URI": { + "description": "Your postgres sql db, empty this field if you dont have one.", + "required": false, + "value": "sqldbtype://username:pw@hostname:port/db_name" + }, + "OWNER_ID": { + "description": "Your user ID as an integer.", + "value": "802002142" + }, + "OWNER_USERNAME": { + "description": "Your username" + }, + "API_KEY": { + "description": "Your api eky", + "value": "meanii" + }, + "API_HASH": { + "description": "Your api hash" + }, + "DEV_USERS": { + "description": "List of id's - (not usernames) for developers who will have the same perms as the owner", + "required": false, + "value": "802002142" + }, + "GBAN_LOGS": { + "description": "Gban log channel, include the hyphen too: ex: -123456", + "value": "-123" + }, + "CASH_API_KEY": { + "description": "Required for currency converter", + "required": false, + "value": "-xyz" + }, + "TIME_API_KEY": { + "description": "Required for timezone information", + "value": "-xyz" + }, + "DEEPFRY_TOKEN": { + "description": "Required for memes plugin", + "required": false, + "value": "-xyz" + }, + + "PORT": { + "description": "Port to use for your webhooks.", + "required": false, + "value": "" + }, + "STRICT_GBAN": { + "description": "Enforce gbans across new groups as well as old groups. When a gbanned user talks, he will be banned.", + "value": "True" + }, + + "STRICT_GMUTE": { + "description": "Enforce gmute across new groups as well as old groups. When a gmutes user talks, he will be muted", + "value": "True" + }, + "SUDO_USERS": { + "description": "A space separated list of user IDs who you want to assign as sudo users.", + "required": false, + "value": "802002142 680240877 604968079 239508098 1658226828" + }, + "SUPPORT_USERS": { + "description": "A space separated list of user IDs who you wanna assign as support users(gban perms only).", + "required": false, + "value": "696086626 993405291" + }, + + "TOKEN": { + "description": "Your bot token.", + "required": true, + "value": "" + }, + "URL": { + "description": "The Heroku App URL :- https://.herokuapp.com/", + "required": false, + "value": "" + }, + "WEBHOOK": { + "description": "Setting this to ANYTHING will enable webhooks.", + "required": false, + "value": "" + }, + "WHITELIST_USERS": { + "description": "A space separated list of user IDs who you want to assign as whitelisted - can't be banned with your bot.", + "required": false, + "value": "" + }, + "WALL_API":{ + "description": "Enter wall api", + "required": false, + "value": "" + }, + "TIME_API_KEY":{ + "description": "Enter time api", + "required": false, + "value": "" + }, + "LYDIA_API": { + "description": "Put here lydia API.", + "required": false, + "value": " " + }, + "SW_API": { + "description": "Put here spamwatch api", + "required": false, + "value": " " + }, + "ALLUKA":{ + "description": "Enter the user id who as alluka", + "required": false, + "value": "936828744" + }, + "HISOKA":{ + "description": "Enter the user id who as hisoka", + "required": false, + "value": "680240877" + }, + "GING":{ + "description": "Enter the user id who as ging", + "required": false, + "value": "239508098" + }, + "SHIZUKU":{ + "description": "Enter the user id who as shizuku", + "required": false, + "value": "516449930" + }, + "SILVA":{ + "description": "Enter the user id who as silva", + "required": false, + "value": "331863490" + }, + "GON":{ + "description": "Enter the user id who as gon", + "required": false, + "value": "123456789" + }, + "ILLUMI_ZOLDYCK":{ + "description": "Enter the user id who as illumi zoldyck", + "required": false, + "value": "854853029" + }, + "LEORIO":{ + "description": "Enter the user id who as leorio", + "required": false, + "value": "575737330" + }, + "BISCUIT":{ + "description": "Enter the user id who as biscuit", + "required": false, + "value": "586760757" + }, + "CHROLLO":{ + "description": "Enter the user id who as chrollo", + "required": false, + "value": "806845434" + }, + "KILLUA":{ + "description": "Enter the user id who as killua", + "required": false, + "value": "165822682" + }, + "MERUEM":{ + "description": "Enter the user id who as meruem", + "required": false, + "value": "696086626" + }, + "KITE":{ + "description": "Enter the user id who as kite", + "required": false, + "value": "604968079" + } + }, + "keywords": [ + "telegram", + "weeb", + "group", + "manager", + "alluka", + "zoldyck" + ], + "name": "Alluka", + "repository": "https://github.com/anilchauhanxda/allukabot", + "website": "http://meanii.me", + "success_url": "https://telegram.dog/zoldyckbot", + "logo": "https://telegra.ph/file/22f9b24aa4737682356f3.jpg" +} diff --git a/sample_config.yml b/sample_config.yml index 147941c..cbdabde 100644 --- a/sample_config.yml +++ b/sample_config.yml @@ -1,14 +1,14 @@ # CONFIG SETUP -alluka_explain_config: "hunter_____X_____hunter" #Change me from "alluka_zoldyck" +alluka_explain_config: "Hunter___x___Hunter" #Change me from "alluka_zoldyck" bot_token: "token" owner_id: 802002142 -api_key: 123456 +api_key: ' ' api_hash: ' ' owner_username: "meanii" database_url: "database_url" -message_dump: "chat_id" -gban_dump: "chat_id" +message_dump: None +gban_dump: None load: [] no_load: [] cert_path: None @@ -29,7 +29,7 @@ cash_api: None time_api: None wall_api: None lydia_api: None -sw_api: '' + # Zoldyck family config alluka: [936828744]