Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #125 from Ghost-IU/autofix
Browse files Browse the repository at this point in the history
Format code.
  • Loading branch information
devops117 authored Mar 14, 2022
2 parents 3b0a3da + c5faaba commit b62f7fc
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 47 deletions.
8 changes: 4 additions & 4 deletions SaitamaRobot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# Config
TELEGRAM_BOT_TOKEN = env.get("TELEGRAM_BOT_TOKEN")

config_file=Path(os.path.join(__name__, "config.yaml"))
yaml=YAML(typ="safe")
config_data=yaml.load(config_file) # look for ./crawl/config.yaml
config_file = Path(os.path.join(__name__, "config.yaml"))
yaml = YAML(typ="safe")
config_data = yaml.load(config_file) # look for ./crawl/config.yaml

OWNER_USERID = int(config_data.get("OWNER_USERID"))
OWNER_USERNAME = config_data.get("OWNER_USERNAME")
Expand Down Expand Up @@ -57,7 +57,7 @@
updater = telegram.ext.Updater(TELEGRAM_BOT_TOKEN)
dispatcher = updater.dispatcher

#telethn = TelegramClient(
# telethn = TelegramClient(
# "saitama",
# env.get("TELEGRAM_API_ID"), env.get("TELEGRAM_API_HASH"),
# )
Expand Down
75 changes: 38 additions & 37 deletions SaitamaRobot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@
from typing import Optional

from telegram import (
InlineKeyboardButton,
InlineKeyboardMarkup,
ParseMode,
Update,
)
InlineKeyboardButton,
InlineKeyboardMarkup,
ParseMode,
Update,
)
from telegram.error import (
BadRequest,
ChatMigrated,
NetworkError,
TelegramError,
TimedOut,
Unauthorized,
)
BadRequest,
ChatMigrated,
NetworkError,
TelegramError,
TimedOut,
Unauthorized,
)
from telegram.ext import (
CallbackContext,
CallbackQueryHandler,
CommandHandler,
Filters,
MessageHandler,
)
CallbackContext,
CallbackQueryHandler,
CommandHandler,
Filters,
MessageHandler,
)

from telegram.ext.dispatcher import DispatcherHandlerStop
from telegram.utils.helpers import escape_markdown

from SaitamaRobot import (
ALLOW_EXCL,
CERT_PATH,
dispatcher,
DONATION_LINK,
LOGGER,
OWNER_USERID,
PORT,
StartTime,
SUPPORT_CHAT,
#telethn,
TELEGRAM_BOT_TOKEN,
updater,
URL,
WEBHOOK,
)
ALLOW_EXCL,
CERT_PATH,
dispatcher,
DONATION_LINK,
LOGGER,
OWNER_USERID,
PORT,
StartTime,
SUPPORT_CHAT,
# telethn,
TELEGRAM_BOT_TOKEN,
updater,
URL,
WEBHOOK,
)

from SaitamaRobot.modules import ALL_MODULES
from SaitamaRobot.modules.helper_funcs.chat_status import is_user_admin
Expand Down Expand Up @@ -106,7 +106,8 @@ def get_readable_time(seconds: int) -> str:

if DONATION_LINK:
DONATE_STRING = (
f"You can donate to the person currently running me [here]({DONATION_LINK})")
f"You can donate to the person currently running me [here]({DONATION_LINK})"
)
else:
DONATE_STRING = """Won't be necessary for now."""

Expand Down Expand Up @@ -670,15 +671,15 @@ def main():
LOGGER.info("Using long polling.")
updater.start_polling(timeout=15, read_latency=4, drop_pending_updates=True)

#if len(sys.argv) not in (1, 3, 4):
# if len(sys.argv) not in (1, 3, 4):
# telethn.disconnect()
#else:
# else:
# telethn.run_until_disconnected()

updater.idle()


if __name__ == "__main__":
LOGGER.info("Successfully loaded modules: " + str(ALL_MODULES))
#telethn.start(bot_token=TELEGRAM_BOT_TOKEN)
# telethn.start(bot_token=TELEGRAM_BOT_TOKEN)
main()
4 changes: 2 additions & 2 deletions SaitamaRobot/modules/disasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
from telegram.ext import CallbackContext, CommandHandler
from telegram.utils.helpers import mention_html

#TODO: fix addsudo and removesudo
# TODO: fix addsudo and removesudo


def check_user_id(user_id: int, context: CallbackContext) -> Optional[str]:
bot = context.bot
Expand Down Expand Up @@ -138,7 +139,6 @@ def removesudo(update: Update, context: CallbackContext) -> str:
return ""



@whitelist_plus
def sudolist(update: Update, context: CallbackContext):
bot = context.bot
Expand Down
5 changes: 4 additions & 1 deletion SaitamaRobot/modules/get_common_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def get_user_common_chats(update: Update, context: CallbackContext):


COMMON_CHATS_HANDLER = CommandHandler(
"getchats", get_user_common_chats, filters=Filters.user(OWNER_USERID), run_async=True
"getchats",
get_user_common_chats,
filters=Filters.user(OWNER_USERID),
run_async=True,
)

dispatcher.add_handler(COMMON_CHATS_HANDLER)
4 changes: 1 addition & 3 deletions SaitamaRobot/modules/userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def get_id(update: Update, context: CallbackContext):


@SaitamaTelethonClient.on(
events.NewMessage(
pattern="/ginfo ", from_users=(DRAGONS | DEV_USERS)
)
events.NewMessage(pattern="/ginfo ", from_users=(DRAGONS | DEV_USERS))
)
async def group_info(event) -> None:
chat = event.text.split(" ", 1)[1]
Expand Down

0 comments on commit b62f7fc

Please sign in to comment.