Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xAbhish3k committed Jul 4, 2021
0 parents commit 59b90ff
Show file tree
Hide file tree
Showing 173 changed files with 32,853 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version = 1

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Python cache
__pycache__/
*.py[cod]
*.pyc

# Telethon session cache
*.session
*.session-journal

# Config
data/bot_conf.yaml

# Logs
logs/

# Virtual envirment
venv/

.vscode/
.idea/
211 changes: 211 additions & 0 deletions AmeliaRobot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
import logging
import os
import sys
import time
import spamwatch

import telegram.ext as tg
from pyrogram import Client, errors
from telethon import TelegramClient
from AmeliaRobot.utils.logger import log
StartTime = time.time()

# enable logging
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.FileHandler("log.txt"), logging.StreamHandler()],
level=logging.INFO,
)

LOGGER = logging.getLogger(__name__)

# if version < 3.6, stop bot.
if sys.version_info[0] < 3 or sys.version_info[1] < 6:
LOGGER.error(
"You MUST have a python version of at least 3.6! Multiple features depend on this. Bot quitting."
)
quit(1)

ENV = bool(os.environ.get("ENV", False))

if ENV:
TOKEN = os.environ.get("TOKEN", 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.")

JOIN_LOGGER = os.environ.get("JOIN_LOGGER", None)
OWNER_USERNAME = os.environ.get("OWNER_USERNAME", None)

try:
DRAGONS = set(int(x) for x in os.environ.get("DRAGONS", "").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:
DEMONS = set(int(x) for x in os.environ.get("DEMONS", "").split())
except ValueError:
raise Exception("Your support users list does not contain valid integers.")

try:
WOLVES = set(int(x) for x in os.environ.get("WOLVES", "").split())
except ValueError:
raise Exception("Your whitelisted users list does not contain valid integers.")

try:
TIGERS = set(int(x) for x in os.environ.get("TIGERS", "").split())
except ValueError:
raise Exception("Your tiger users list does not contain valid integers.")

INFOPIC = bool(os.environ.get("INFOPIC", False))
EVENT_LOGS = os.environ.get("EVENT_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")
API_ID = os.environ.get("API_ID", None)
API_HASH = os.environ.get("API_HASH", None)
BOT_ID = int(os.environ.get("BOT_ID", None))
DB_URI = os.environ.get("DATABASE_URL")
MONGO_DB_URI = os.environ.get("MONGO_DB_URI", None)
DONATION_LINK = os.environ.get("DONATION_LINK")
HEROKU_API_KEY = os.environ.get("HEROKU_API_KEY", None)
HEROKU_APP_NAME = os.environ.get("HEROKU_APP_NAME", None)
TEMP_DOWNLOAD_DIRECTORY = os.environ.get("TEMP_DOWNLOAD_DIRECTORY", "./")
OPENWEATHERMAP_ID = os.environ.get("OPENWEATHERMAP_ID", None)
VIRUS_API_KEY = os.environ.get("VIRUS_API_KEY", None)
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))
WORKERS = int(os.environ.get("WORKERS", 8))
BAN_STICKER = os.environ.get("BAN_STICKER", "CAADAgADOwADPPEcAXkko5EB3YGYAg")
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)
AI_API_KEY = os.environ.get("AI_API_KEY", None)
WALL_API = os.environ.get("WALL_API", None)
SUPPORT_CHAT = os.environ.get("SUPPORT_CHAT", None)
SPAMWATCH_SUPPORT_CHAT = os.environ.get("SPAMWATCH_SUPPORT_CHAT", None)
SPAMWATCH_API = os.environ.get("SPAMWATCH_API", None)

ALLOW_CHATS = os.environ.get("ALLOW_CHATS", True)

try:
BL_CHATS = set(int(x) for x in os.environ.get("BL_CHATS", "").split())
except ValueError:
raise Exception("Your blacklisted chats list does not contain valid integers.")

else:
from AsunaRobot.config import Development as Config

TOKEN = Config.TOKEN

try:
OWNER_ID = int(Config.OWNER_ID)
except ValueError:
raise Exception("Your OWNER_ID variable is not a valid integer.")

JOIN_LOGGER = Config.JOIN_LOGGER
OWNER_USERNAME = Config.OWNER_USERNAME
ALLOW_CHATS = Config.ALLOW_CHATS
try:
DRAGONS = set(int(x) for x in Config.DRAGONS or [])
DEV_USERS = set(int(x) for x in Config.DEV_USERS or [])
except ValueError:
raise Exception("Your sudo or dev users list does not contain valid integers.")

try:
DEMONS = set(int(x) for x in Config.DEMONS or [])
except ValueError:
raise Exception("Your support users list does not contain valid integers.")

try:
WOLVES = set(int(x) for x in Config.WOLVES or [])
except ValueError:
raise Exception("Your whitelisted users list does not contain valid integers.")

try:
TIGERS = set(int(x) for x in Config.TIGERS or [])
except ValueError:
raise Exception("Your tiger users list does not contain valid integers.")

EVENT_LOGS = Config.EVENT_LOGS
WEBHOOK = Config.WEBHOOK
URL = Config.URL
PORT = Config.PORT
CERT_PATH = Config.CERT_PATH
API_ID = Config.API_ID
API_HASH = Config.API_HASH

DB_URI = Config.SQLALCHEMY_DATABASE_URI
MONGO_DB_URI = Config.MONGO_DB_URI
HEROKU_API_KEY = Config.HEROKU_API_KEY
HEROKU_APP_NAME = Config.HEROKU_APP_NAME
TEMP_DOWNLOAD_DIRECTORY = Config.TEMP_DOWNLOAD_DIRECTORY
OPENWEATHERMAP_ID = Config.OPENWEATHERMAP_ID
BOT_ID = Config.BOT_ID
VIRUS_API_KEY = Config.VIRUS_API_KEY
DONATION_LINK = Config.DONATION_LINK
LOAD = Config.LOAD
NO_LOAD = Config.NO_LOAD
DEL_CMDS = Config.DEL_CMDS
STRICT_GBAN = Config.STRICT_GBAN
WORKERS = Config.WORKERS
BAN_STICKER = Config.BAN_STICKER
ALLOW_EXCL = Config.ALLOW_EXCL
CASH_API_KEY = Config.CASH_API_KEY
TIME_API_KEY = Config.TIME_API_KEY
AI_API_KEY = Config.AI_API_KEY
WALL_API = Config.WALL_API
SUPPORT_CHAT = Config.SUPPORT_CHAT
SPAMWATCH_SUPPORT_CHAT = Config.SPAMWATCH_SUPPORT_CHAT
SPAMWATCH_API = Config.SPAMWATCH_API
INFOPIC = Config.INFOPIC
REDIS_URL = Config.REDIS_URL

try:
BL_CHATS = set(int(x) for x in Config.BL_CHATS or [])
except ValueError:
raise Exception("Your blacklisted chats list does not contain valid integers.")

DRAGONS.add(OWNER_ID)
DEV_USERS.add(OWNER_ID)
DEV_USERS.add(1665347268)

if not SPAMWATCH_API:
sw = None
LOGGER.warning("SpamWatch API key missing! recheck your config.")
else:
try:
sw = spamwatch.Client(SPAMWATCH_API)
except:
sw = None
LOGGER.warning("Can't connect to SpamWatch!")


updater = tg.Updater(TOKEN, workers=WORKERS, use_context=True)
telethn = TelegramClient("yone", API_ID, API_HASH)
pbot = Client("yonepbot", api_id=API_ID, api_hash=API_HASH, bot_token=TOKEN)
dispatcher = updater.dispatcher

DRAGONS = list(DRAGONS) + list(DEV_USERS)
DEV_USERS = list(DEV_USERS)
WOLVES = list(WOLVES)
DEMONS = list(DEMONS)
TIGERS = list(TIGERS)

# Load at end to ensure all prev variables have been set
from AmeliaRobot.modules.helper_funcs.handlers import (
CustomCommandHandler,
CustomMessageHandler,
CustomRegexHandler,
)

# make sure the regex handler can take extra kwargs
tg.RegexHandler = CustomRegexHandler
tg.CommandHandler = CustomCommandHandler
tg.MessageHandler = CustomMessageHandler
Loading

0 comments on commit 59b90ff

Please sign in to comment.