Skip to content

Commit

Permalink
Automated code formatting
Browse files Browse the repository at this point in the history
Signed-off-by: kennedy-ex <[email protected]>
  • Loading branch information
kennedy-ex committed Mar 27, 2022
1 parent f2b6218 commit 494ba34
Show file tree
Hide file tree
Showing 73 changed files with 1,206 additions and 981 deletions.
11 changes: 8 additions & 3 deletions EmikoRobot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@

StartTime = time.time()


def get_user_list(__init__, key):
with open("{}/EmikoRobot/{}".format(os.getcwd(), __init__), "r") as json_file:
return json.load(json_file)[key]


# enable logging
FORMAT = "[EmikoRobot] %(message)s"
logging.basicConfig(
Expand All @@ -35,9 +37,11 @@ def get_user_list(__init__, key):
datefmt="[%X]",
)
logging.getLogger("pyrogram").setLevel(logging.INFO)
logging.getLogger('ptbcontrib.postgres_persistence.postgrespersistence').setLevel(logging.WARNING)
logging.getLogger("ptbcontrib.postgres_persistence.postgrespersistence").setLevel(
logging.WARNING
)

LOGGER = logging.getLogger('[EmikoRobot]')
LOGGER = logging.getLogger("[EmikoRobot]")
LOGGER.info("Emiko is starting. | An Kennedy Project Parts. | Licensed under GPLv3.")
LOGGER.info("Not affiliated to other anime or Villain in any way whatsoever.")
LOGGER.info("Project maintained by: github.com/kennedy-ex (t.me/excrybaby)")
Expand Down Expand Up @@ -75,7 +79,7 @@ def get_user_list(__init__, key):

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

try:
Expand Down Expand Up @@ -258,6 +262,7 @@ def get_user_list(__init__, key):
apps.append(pbot)
loop = asyncio.get_event_loop()


async def get_entity(client, entity):
entity_client = client
if not isinstance(entity, Chat):
Expand Down
195 changes: 115 additions & 80 deletions EmikoRobot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,12 @@ def get_readable_time(seconds: int) -> str:
],
[
InlineKeyboardButton(text="Get Help", callback_data="help_back"),
InlineKeyboardButton(
text="Try inline!​​", switch_inline_query_current_chat=""
),
InlineKeyboardButton(text="Try inline!​​", switch_inline_query_current_chat=""),
],
[
InlineKeyboardButton(
text="➗ Add Emiko To Your Group ➗", url=f"t.me/{bu}?startgroup=new"),
text="➗ Add Emiko To Your Group ➗", url=f"t.me/{bu}?startgroup=new"
),
],
]

Expand Down Expand Up @@ -198,7 +197,13 @@ def start(update: Update, context: CallbackContext):
update.effective_chat.id,
HELPABLE[mod].__help__,
InlineKeyboardMarkup(
[[InlineKeyboardButton(text="Go Back", callback_data="help_back")]]
[
[
InlineKeyboardButton(
text="Go Back", callback_data="help_back"
)
]
]
),
)

Expand All @@ -221,7 +226,8 @@ def start(update: Update, context: CallbackContext):
escape_markdown(first_name),
escape_markdown(uptime),
sql.num_users(),
sql.num_chats()),
sql.num_chats(),
),
reply_markup=InlineKeyboardMarkup(buttons),
parse_mode=ParseMode.MARKDOWN,
timeout=60,
Expand All @@ -230,8 +236,8 @@ def start(update: Update, context: CallbackContext):
else:
update.effective_message.reply_text(
f"👋 Hi, I'm {dispatcher.bot.first_name}. Nice to meet You.",
parse_mode=ParseMode.HTML
)
parse_mode=ParseMode.HTML,
)


def error_handler(update, context):
Expand Down Expand Up @@ -373,36 +379,48 @@ def emiko_about_callback(update, context):
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(text="Admins", callback_data="emiko_admin"),
InlineKeyboardButton(text="Notes", callback_data="emiko_notes"),
],
[
InlineKeyboardButton(text="Support", callback_data="emiko_support"),
InlineKeyboardButton(text="Credits", callback_data="emiko_credit"),
],
[
InlineKeyboardButton(text="Source Code", url="https://github.com/kennedy-ex/EmikoRobot"),
],
[
InlineKeyboardButton(text="Go Back", callback_data="emiko_back"),
]
[
InlineKeyboardButton(
text="Admins", callback_data="emiko_admin"
),
InlineKeyboardButton(text="Notes", callback_data="emiko_notes"),
],
[
InlineKeyboardButton(
text="Support", callback_data="emiko_support"
),
InlineKeyboardButton(
text="Credits", callback_data="emiko_credit"
),
],
[
InlineKeyboardButton(
text="Source Code",
url="https://github.com/kennedy-ex/EmikoRobot",
),
],
[
InlineKeyboardButton(
text="Go Back", callback_data="emiko_back"
),
],
]
),
)
elif query.data == "emiko_back":
first_name = update.effective_user.first_name
uptime = get_readable_time((time.time() - StartTime))
query.message.edit_text(
PM_START_TEXT.format(
escape_markdown(first_name),
escape_markdown(uptime),
sql.num_users(),
sql.num_chats()),
reply_markup=InlineKeyboardMarkup(buttons),
parse_mode=ParseMode.MARKDOWN,
timeout=60,
disable_web_page_preview=False,
PM_START_TEXT.format(
escape_markdown(first_name),
escape_markdown(uptime),
sql.num_users(),
sql.num_chats(),
),
reply_markup=InlineKeyboardMarkup(buttons),
parse_mode=ParseMode.MARKDOWN,
timeout=60,
disable_web_page_preview=False,
)

elif query.data == "emiko_admin":
Expand Down Expand Up @@ -440,53 +458,74 @@ def emiko_about_callback(update, context):
parse_mode=ParseMode.MARKDOWN,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(text="Support", url="t.me/emikosupport"),
InlineKeyboardButton(text="Updates", url="https://t.me/KennedyProject"),
],
[
InlineKeyboardButton(text="Go Back", callback_data="emiko_"),

]
[
InlineKeyboardButton(text="Support", url="t.me/emikosupport"),
InlineKeyboardButton(
text="Updates", url="https://t.me/KennedyProject"
),
],
[
InlineKeyboardButton(text="Go Back", callback_data="emiko_"),
],
]
),
)


elif query.data == "emiko_credit":
query.message.edit_text(
text=f"๏ Credis for Emiko\n"
"\nHere Developers Making And Give Inspiration For Made The EmikoRobot",
parse_mode=ParseMode.MARKDOWN,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(text="sena-ex", url="https://github.com/kennedy-ex"),
InlineKeyboardButton(text="TheHamkerCat", url="https://github.com/TheHamkerCat"),
],
[
InlineKeyboardButton(text="Feri", url="https://github.com/FeriEXP"),
InlineKeyboardButton(text="riz-ex", url="https://github.com/riz-ex"),
],
[
InlineKeyboardButton(text="Anime Kaizoku", url="https://github.com/animekaizoku"),
InlineKeyboardButton(text="TheGhost Hunter", url="https://github.com/HuntingBots"),
],
[
InlineKeyboardButton(text="Inuka Asith", url="https://github.com/inukaasith"),
InlineKeyboardButton(text="Noob-Kittu", url="https://github.com/noob-kittu"),
],
[
InlineKeyboardButton(text="Queen Arzoo", url="https://github.com/QueenArzoo"),
InlineKeyboardButton(text="Paul Larsen", url="https://github.com/PaulSonOfLars"),
],
[
InlineKeyboardButton(text="Go Back", callback_data="emiko_"),
]
[
InlineKeyboardButton(
text="sena-ex", url="https://github.com/kennedy-ex"
),
InlineKeyboardButton(
text="TheHamkerCat", url="https://github.com/TheHamkerCat"
),
],
[
InlineKeyboardButton(
text="Feri", url="https://github.com/FeriEXP"
),
InlineKeyboardButton(
text="riz-ex", url="https://github.com/riz-ex"
),
],
[
InlineKeyboardButton(
text="Anime Kaizoku", url="https://github.com/animekaizoku"
),
InlineKeyboardButton(
text="TheGhost Hunter", url="https://github.com/HuntingBots"
),
],
[
InlineKeyboardButton(
text="Inuka Asith", url="https://github.com/inukaasith"
),
InlineKeyboardButton(
text="Noob-Kittu", url="https://github.com/noob-kittu"
),
],
[
InlineKeyboardButton(
text="Queen Arzoo", url="https://github.com/QueenArzoo"
),
InlineKeyboardButton(
text="Paul Larsen", url="https://github.com/PaulSonOfLars"
),
],
[
InlineKeyboardButton(text="Go Back", callback_data="emiko_"),
],
]
),
)


def Source_about_callback(update, context):
query = update.callback_query
if query.data == "source_":
Expand All @@ -505,27 +544,25 @@ def Source_about_callback(update, context):
parse_mode=ParseMode.MARKDOWN,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(text="Go Back", callback_data="emiko_")
]
]
[[InlineKeyboardButton(text="Go Back", callback_data="emiko_")]]
),
)
elif query.data == "source_back":
first_name = update.effective_user.first_name
query.message.edit_text(
PM_START_TEXT.format(
escape_markdown(first_name),
escape_markdown(uptime),
sql.num_users(),
sql.num_chats()),
reply_markup=InlineKeyboardMarkup(buttons),
parse_mode=ParseMode.MARKDOWN,
timeout=60,
disable_web_page_preview=False,
PM_START_TEXT.format(
escape_markdown(first_name),
escape_markdown(uptime),
sql.num_users(),
sql.num_chats(),
),
reply_markup=InlineKeyboardMarkup(buttons),
parse_mode=ParseMode.MARKDOWN,
timeout=60,
disable_web_page_preview=False,
)


def get_help(update: Update, context: CallbackContext):
chat = update.effective_chat # type: Optional[Chat]
args = update.effective_message.text.split(None, 1)
Expand Down Expand Up @@ -797,9 +834,7 @@ def main():
if SUPPORT_CHAT is not None and isinstance(SUPPORT_CHAT, str):
try:
dispatcher.bot.sendMessage(
f"@{SUPPORT_CHAT}",
"👋 Hi, i'm alive.",
parse_mode=ParseMode.MARKDOWN
f"@{SUPPORT_CHAT}", "👋 Hi, i'm alive.", parse_mode=ParseMode.MARKDOWN
)
except Unauthorized:
LOGGER.warning(
Expand Down
23 changes: 12 additions & 11 deletions EmikoRobot/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
db = client["emiexrobot"]
gbanned = db.gban


def register(**args):
""" Registers a new message. """
"""Registers a new message."""
pattern = args.get("pattern", None)

r_pattern = r"^[/!.]"
Expand All @@ -34,7 +35,7 @@ def decorator(func):


def chataction(**args):
""" Registers chat actions. """
"""Registers chat actions."""

def decorator(func):
telethn.add_event_handler(func, events.ChatAction(**args))
Expand All @@ -44,7 +45,7 @@ def decorator(func):


def userupdate(**args):
""" Registers user updates. """
"""Registers user updates."""

def decorator(func):
telethn.add_event_handler(func, events.UserUpdate(**args))
Expand All @@ -54,7 +55,7 @@ def decorator(func):


def inlinequery(**args):
""" Registers inline query. """
"""Registers inline query."""
pattern = args.get("pattern", None)

if pattern is not None and not pattern.startswith("(?i)"):
Expand All @@ -68,7 +69,7 @@ def decorator(func):


def callbackquery(**args):
""" Registers inline query. """
"""Registers inline query."""

def decorator(func):
telethn.add_event_handler(func, events.CallbackQuery(**args))
Expand Down Expand Up @@ -118,12 +119,12 @@ async def wrapper(check):
print("i don't work in channels")
return
if check.is_group:
if check.chat.megagroup:
pass
else:
print("i don't work in small chats")
return
if check.chat.megagroup:
pass
else:
print("i don't work in small chats")
return

users = gbanned.find({})
for c in users:
if check.sender_id == c["user"]:
Expand Down
Loading

0 comments on commit 494ba34

Please sign in to comment.