Skip to content
This repository was archived by the owner on Nov 7, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
107 changes: 84 additions & 23 deletions alluka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import yaml
import spamwatch
import os
from telethon import TelegramClient
import telegram.ext as tg

Expand All @@ -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)
Expand All @@ -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'])

Expand Down Expand Up @@ -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)
Expand Down
37 changes: 8 additions & 29 deletions alluka/modules/antispam.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
"<b>This user is detected as a spambot by SpamWatch and has been removed!</b>\n\n<b>Reason</b>: {}").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):
Expand Down
2 changes: 1 addition & 1 deletion alluka/modules/blacklist_stickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading