Skip to content
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
6 changes: 3 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
PROTECT_CONTENT = strtobool(os.environ.get("PROTECT_CONTENT", "False"))

# Heroku Credentials for updater.
HEROKU_APP_NAME = os.environ.get("HEROKU_APP_NAME", None)
HEROKU_API_KEY = os.environ.get("HEROKU_API_KEY", None)
HEROKU_APP_NAME = os.environ.get("HEROKU_APP_NAME")
HEROKU_API_KEY = os.environ.get("HEROKU_API_KEY")
Comment on lines -32 to +33
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 32-64 refactored with the following changes:


# Custom Repo for updater.
UPSTREAM_BRANCH = os.environ.get("UPSTREAM_BRANCH", "master")
Expand Down Expand Up @@ -61,7 +61,7 @@
)

# Atur Teks Kustom Anda di sini, Simpan (None) untuk Menonaktifkan Teks Kustom
CUSTOM_CAPTION = os.environ.get("CUSTOM_CAPTION", None)
CUSTOM_CAPTION = os.environ.get("CUSTOM_CAPTION")

# Setel True jika Anda ingin Menonaktifkan tombol Bagikan Kiriman Saluran Anda
DISABLE_CHANNEL_BUTTON = strtobool(os.environ.get("DISABLE_CHANNEL_BUTTON", "False"))
Expand Down
12 changes: 5 additions & 7 deletions helper_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,13 @@ async def is_subscribed(filter, client, update):
async def encode(string):
string_bytes = string.encode("ascii")
base64_bytes = base64.urlsafe_b64encode(string_bytes)
base64_string = (base64_bytes.decode("ascii")).strip("=")
return base64_string
return (base64_bytes.decode("ascii")).strip("=")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function encode refactored with the following changes:


async def decode(base64_string):
base64_string = base64_string.strip("=") # links generated before this commit will be having = sign, hence striping them to handle padding errors.
base64_bytes = (base64_string + "=" * (-len(base64_string) % 4)).encode("ascii")
string_bytes = base64.urlsafe_b64decode(base64_bytes)
string = string_bytes.decode("ascii")
return string
string_bytes = base64.urlsafe_b64decode(base64_bytes)
return string_bytes.decode("ascii")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function decode refactored with the following changes:



async def get_messages(client, message_ids):
Expand Down Expand Up @@ -113,8 +111,8 @@ async def get_message_id(client, message):
matches = re.match(pattern, message.text)
if not matches:
return 0
channel_id = matches.group(1)
msg_id = int(matches.group(2))
channel_id = matches[1]
msg_id = int(matches[2])
Comment on lines -116 to +115
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_message_id refactored with the following changes:

if channel_id.isdigit():
if f"-100{channel_id}" == str(client.db_channel.id):
return msg_id
Expand Down
60 changes: 33 additions & 27 deletions plugins/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,54 @@


def start_button(client):
if not FORCE_SUB_CHANNEL and not FORCE_SUB_GROUP:
buttons = [
if not FORCE_SUB_CHANNEL:
return (
[
InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"),
InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"),
],
]
return buttons
if not FORCE_SUB_CHANNEL and FORCE_SUB_GROUP:
buttons = [
[
InlineKeyboardButton(text="ɢʀᴏᴜᴘ", url=client.invitelink2),
],
[
InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"),
InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"),
],
]
return buttons
if FORCE_SUB_CHANNEL and not FORCE_SUB_GROUP:
buttons = [
[
InlineKeyboardButton(text="ɢʀᴏᴜᴘ", url=client.invitelink2),
],
[
InlineKeyboardButton(
text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"
),
InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"),
],
]
if FORCE_SUB_GROUP
else [
[
InlineKeyboardButton(
text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"
),
InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"),
],
]
)
if not FORCE_SUB_GROUP:
return [
[
InlineKeyboardButton(text="ᴄʜᴀɴɴᴇʟ", url=client.invitelink),
],
[
InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"),
InlineKeyboardButton(
text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"
),
InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"),
],
]
return buttons
if FORCE_SUB_CHANNEL and FORCE_SUB_GROUP:
buttons = [
if FORCE_SUB_CHANNEL:
return [
[
InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"),
InlineKeyboardButton(
text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"
),
Comment on lines -10 to +50
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function start_button refactored with the following changes:

],
[
InlineKeyboardButton(text="ᴄʜᴀɴɴᴇʟ", url=client.invitelink),
InlineKeyboardButton(text="ɢʀᴏᴜᴘ", url=client.invitelink2),
],
[InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close")],
]
return buttons


def fsub_button(client, message):
Expand Down Expand Up @@ -88,7 +94,7 @@ def fsub_button(client, message):
except IndexError:
pass
return buttons
if FORCE_SUB_CHANNEL and FORCE_SUB_GROUP:
if FORCE_SUB_CHANNEL:
Comment on lines -91 to +97
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fsub_button refactored with the following changes:

buttons = [
[
InlineKeyboardButton(text="ᴊᴏɪɴ ᴄʜᴀɴɴᴇʟ", url=client.invitelink),
Expand Down
19 changes: 8 additions & 11 deletions plugins/heroku.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ async def varget_(client: Bot, message: Message):
path = dotenv.find_dotenv("config.env")
if not path:
return await message.reply_text(".env file not found.")
output = dotenv.get_key(path, check_var)
if not output:
await message.reply_text(f"Tidak dapat menemukan var {check_var}")
else:
if output := dotenv.get_key(path, check_var):
return await message.reply_text(
f"<b>{check_var}:</b> <code>{str(output)}</code>"
)
else:
await message.reply_text(f"Tidak dapat menemukan var {check_var}")
Comment on lines -76 to +81
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function varget_ refactored with the following changes:



@Bot.on_message(filters.command("delvar") & filters.user(ADMINS))
Expand All @@ -93,21 +92,19 @@ async def vardel_(client: Bot, message: Message):
"Pastikan HEROKU_API_KEY dan HEROKU_APP_NAME anda dikonfigurasi dengan benar di config vars heroku"
)
heroku_config = HAPP.config()
if check_var in heroku_config:
await message.reply_text(f"Berhasil Menghapus var {check_var}")
del heroku_config[check_var]
else:
if check_var not in heroku_config:
return await message.reply_text(f"Tidak dapat menemukan var {check_var}")
await message.reply_text(f"Berhasil Menghapus var {check_var}")
del heroku_config[check_var]
Comment on lines -96 to +98
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function vardel_ refactored with the following changes:

else:
path = dotenv.find_dotenv("config.env")
if not path:
return await message.reply_text(".env file not found.")
output = dotenv.unset_key(path, check_var)
if not output[0]:
return await message.reply_text(f"Tidak dapat menemukan var {check_var}")
else:
await message.reply_text(f"Berhasil Menghapus var {check_var}")
os.system(f"kill -9 {os.getpid()} && bash start")
await message.reply_text(f"Berhasil Menghapus var {check_var}")
os.system(f"kill -9 {os.getpid()} && bash start")


@Bot.on_message(filters.command("setvar") & filters.user(ADMINS))
Expand Down
3 changes: 1 addition & 2 deletions plugins/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ def updater():
async def update_bot(_, message: Message):
message.chat.id
msg = await message.reply_text("Checking updates...")
update_avail = updater()
if update_avail:
if update_avail := updater():
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function update_bot refactored with the following changes:

await msg.edit("✅ Update finished !")
system("git pull -f && pip3 install --no-cache-dir -r requirements.txt")
execle(sys.executable, sys.executable, "main.py", environ)
Expand Down