diff --git a/Data.py b/Data.py
new file mode 100644
index 00000000..4c88e5f1
--- /dev/null
+++ b/Data.py
@@ -0,0 +1,57 @@
+# Credits: @mrismanaziz
+# FROM File-Sharing-Man
+# t.me/SharingUserbot & t.me/Lunatic0de
+
+from pyrogram.types import InlineKeyboardButton
+
+class Data:
+ HELP = """
+ ❏ Perintah untuk Pengguna BOT
+ ├ /start - Mulai Bot
+ ├ /about - Tentang Bot ini
+ ├ /help - Bantuan Perintah Bot ini
+ ├ /ping - Untuk mengecek bot hidup
+ └ /uptime - Untuk melihat status bot
+
+ ❏ Perintah Untuk Admin BOT
+ ├ /logs - Untuk melihat logs bot
+ ├ /vars - Untuk melihat variable bot
+ ├ /setvar - Untuk mengatur var dengan command dibot
+ ├ /delvar - Untuk menghapus var dengan command dibot
+ ├ /getvar - Untuk melihat salah satu var dengan command dibot
+ ├ /users - Untuk melihat statistik pengguna bot
+ ├ /batch - Untuk membuat link lebih dari satu file
+ ├ /speedtest - Untuk Mengetes kecepatan server bot
+ └ /broadcast - Untuk mengirim pesan broadcast ke pengguna bot
+
+👨💻 Develoved by @Lunatic0de
+"""
+
+ close = [
+ [InlineKeyboardButton("ᴛᴜᴛᴜᴘ", callback_data="close")]
+ ]
+
+ mbuttons = [
+ [
+ InlineKeyboardButton("ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"),
+ InlineKeyboardButton("ᴛᴜᴛᴜᴘ", callback_data="close")
+ ],
+ ]
+
+ buttons = [
+ [
+ InlineKeyboardButton("ᴛᴇɴᴛᴀɴɢ sᴀʏᴀ", callback_data="about"),
+ InlineKeyboardButton("ᴛᴜᴛᴜᴘ", callback_data="close")
+ ],
+ ]
+
+ ABOUT = """
+Tentang Bot ini:
+
+@{} adalah Bot Telegram untuk menyimpan Postingan atau File yang dapat Diakses melalui Link Khusus.
+ • Creator: @{}
+ • Source Code: File-Sharing-Man v4
+ • Owner Repo: @mrismanaziz
+
+👨💻 Develoved by @Lunatic0de
+"""
diff --git a/app.json b/app.json
index 0b0d248d..f89f4f1d 100644
--- a/app.json
+++ b/app.json
@@ -6,7 +6,6 @@
"file",
"sharing"
],
- "repository": "https://github.com/mrismanaziz/File-Sharing-Man",
"logo": "https://telegra.ph/file/9dc4e335feaaf6a214818.jpg",
"env": {
"TG_BOT_TOKEN": {
@@ -27,16 +26,20 @@
},
"APP_ID": {
"description": "Dapatkan APP ID di web my.telegram.org",
- "value": ""
+ "value": "6"
},
"API_HASH": {
"description": "Dapatkan API HASH di web my.telegram.org",
- "value": ""
+ "value": "eb06d4abfb49dc3eeb1aeb98ae0f581e"
},
"CHANNEL_ID": {
"description": "Masukan ID Channel Untuk [Channel Database]",
"value": "-100"
},
+ "PROTECT_CONTENT": {
+ "description": "Untuk Mencegah pengguna bot untuk mendownload/memforward/mengscreenshot konten yang dikirim di bot [ Bila ingin diaktifkan ubah ke True ]",
+ "value": "False"
+ },
"FORCE_SUB_CHANNEL": {
"description": "Masukan ID dari Channel Atau Group Untuk Wajib Subscribenya, Bila tidak ingin dipakai Fsubnya, isi dengan 0",
"value": "0"
diff --git a/bot.py b/bot.py
index dbf63388..a7793ed1 100644
--- a/bot.py
+++ b/bot.py
@@ -38,6 +38,9 @@ async def start(self):
usr_bot_me = await self.get_me()
self.username = usr_bot_me.username
self.namebot = usr_bot_me.first_name
+ self.LOGGER(__name__).info(
+ f"TG_BOT_TOKEN detected!\n┌ First Name: {self.namebot}\n└ Username: @{self.username}\n——"
+ )
except Exception as a:
self.LOGGER(__name__).warning(a)
self.LOGGER(__name__).info(
@@ -47,11 +50,15 @@ async def start(self):
if FORCE_SUB_CHANNEL:
try:
- link = (await self.get_chat(FORCE_SUB_CHANNEL)).invite_link
+ info = await self.get_chat(FORCE_SUB_CHANNEL)
+ link = info.invite_link
if not link:
await self.export_chat_invite_link(FORCE_SUB_CHANNEL)
- link = (await self.get_chat(FORCE_SUB_CHANNEL)).invite_link
+ link = info.invite_link
self.invitelink = link
+ self.LOGGER(__name__).info(
+ f"FORCE_SUB_CHANNEL detected!\n┌ Title: {info.title}\n└ Chat ID: {info.id}\n——"
+ )
except Exception as a:
self.LOGGER(__name__).warning(a)
self.LOGGER(__name__).warning(
@@ -67,11 +74,15 @@ async def start(self):
if FORCE_SUB_GROUP:
try:
- link = (await self.get_chat(FORCE_SUB_GROUP)).invite_link
+ info = await self.get_chat(FORCE_SUB_GROUP)
+ link = info.invite_link
if not link:
await self.export_chat_invite_link(FORCE_SUB_GROUP)
- link = (await self.get_chat(FORCE_SUB_GROUP)).invite_link
+ link = info.invite_link
self.invitelink2 = link
+ self.LOGGER(__name__).info(
+ f"FORCE_SUB_GROUP detected!\n┌ Title: {info.title}\n└ Chat ID: {info.id}\n——"
+ )
except Exception as a:
self.LOGGER(__name__).warning(a)
self.LOGGER(__name__).warning(
@@ -88,8 +99,11 @@ async def start(self):
try:
db_channel = await self.get_chat(CHANNEL_ID)
self.db_channel = db_channel
- test = await self.send_message(chat_id=db_channel.id, text="Test Message")
+ test = await self.send_message(chat_id=db_channel.id, text="Test Message", disable_notification=True)
await test.delete()
+ self.LOGGER(__name__).info(
+ f"CHANNEL_ID Database detected!\n┌ Title: {db_channel.title}\n└ Chat ID: {db_channel.id}\n——"
+ )
except Exception as e:
self.LOGGER(__name__).warning(e)
self.LOGGER(__name__).warning(
diff --git a/config.py b/config.py
index bcf96bcf..2ce4afc4 100644
--- a/config.py
+++ b/config.py
@@ -4,6 +4,7 @@
import logging
import os
+from distutils.util import strtobool
from dotenv import load_dotenv
from logging.handlers import RotatingFileHandler
@@ -27,6 +28,16 @@
# NAMA OWNER
OWNER = os.environ.get("OWNER", "mrismanaziz")
+# Protect Content
+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)
+
+# Custom Repo for updater.
+UPSTREAM_BRANCH = os.environ.get("UPSTREAM_BRANCH", "master")
+
# Database
DB_URI = os.environ.get("DATABASE_URL", "")
@@ -56,12 +67,12 @@
CUSTOM_CAPTION = os.environ.get("CUSTOM_CAPTION", None)
# Setel True jika Anda ingin Menonaktifkan tombol Bagikan Kiriman Saluran Anda
-DISABLE_CHANNEL_BUTTON = os.environ.get("DISABLE_CHANNEL_BUTTON", None) == "True"
+DISABLE_CHANNEL_BUTTON = strtobool(os.environ.get("DISABLE_CHANNEL_BUTTON", "False"))
ADMINS.append(OWNER_ID)
# Jangan Dihapus nanti ERROR, HAPUS ID Dibawah ini = TERIMA KONSEKUENSI
# Spoiler KONSEKUENSI-nya Paling CH nya tiba tiba ilang & owner nya gua gban 🤪
-ADMINS.extend((OWNER_ID, 844432220, 1250450587, 1750080384, 2102118281))
+ADMINS.extend((OWNER_ID, 844432220, 1250450587, 1750080384, 182990552))
LOG_FILE_NAME = "logs.txt"
diff --git a/plugins/button.py b/plugins/button.py
index 1b099566..15986671 100644
--- a/plugins/button.py
+++ b/plugins/button.py
@@ -10,8 +10,8 @@ def start_button(client):
if not FORCE_SUB_CHANNEL and not FORCE_SUB_GROUP:
buttons = [
[
- InlineKeyboardButton(text="• ᴛᴇɴᴛᴀɴɢ sᴀʏᴀ •", callback_data="about"),
- InlineKeyboardButton(text="• ᴛᴜᴛᴜᴘ •", callback_data="close"),
+ InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"),
+ InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"),
],
]
return buttons
@@ -21,8 +21,8 @@ def start_button(client):
InlineKeyboardButton(text="ɢʀᴏᴜᴘ", url=client.invitelink2),
],
[
- InlineKeyboardButton(text="• ᴛᴇɴᴛᴀɴɢ sᴀʏᴀ •", callback_data="about"),
- InlineKeyboardButton(text="• ᴛᴜᴛᴜᴘ •", callback_data="close"),
+ InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"),
+ InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"),
],
]
return buttons
@@ -32,21 +32,21 @@ def start_button(client):
InlineKeyboardButton(text="ᴄʜᴀɴɴᴇʟ", url=client.invitelink),
],
[
- InlineKeyboardButton(text="• ᴛᴇɴᴛᴀɴɢ sᴀʏᴀ •", callback_data="about"),
- InlineKeyboardButton(text="• ᴛᴜᴛᴜᴘ •", callback_data="close"),
+ InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"),
+ InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close"),
],
]
return buttons
if FORCE_SUB_CHANNEL and FORCE_SUB_GROUP:
buttons = [
[
- InlineKeyboardButton(text="• ᴛᴇɴᴛᴀɴɢ sᴀʏᴀ •", callback_data="about"),
+ InlineKeyboardButton(text="ʜᴇʟᴘ & ᴄᴏᴍᴍᴀɴᴅs", callback_data="help"),
],
[
InlineKeyboardButton(text="ᴄʜᴀɴɴᴇʟ", url=client.invitelink),
InlineKeyboardButton(text="ɢʀᴏᴜᴘ", url=client.invitelink2),
],
- [InlineKeyboardButton(text="• ᴛᴜᴛᴜᴘ •", callback_data="close")],
+ [InlineKeyboardButton(text="ᴛᴜᴛᴜᴘ", callback_data="close")],
]
return buttons
diff --git a/plugins/cbb.py b/plugins/cbb.py
index 58f37ed0..f4a1e509 100644
--- a/plugins/cbb.py
+++ b/plugins/cbb.py
@@ -2,23 +2,54 @@
# Recode by @mrismanaziz
# t.me/SharingUserbot & t.me/Lunatic0de
-from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup
-
from bot import Bot
from config import OWNER
+from Data import Data
+from pyrogram import filters
+from pyrogram.errors import MessageNotModified
+from pyrogram.types import CallbackQuery, InlineKeyboardMarkup, Message
+
+
+@Bot.on_message(filters.private & filters.incoming & filters.command("about"))
+async def _about(client: Bot, msg: Message):
+ await client.send_message(
+ msg.chat.id,
+ Data.ABOUT.format(client.username, OWNER),
+ disable_web_page_preview=True,
+ reply_markup=InlineKeyboardMarkup(Data.mbuttons),
+ )
+
+
+@Bot.on_message(filters.private & filters.incoming & filters.command("help"))
+async def _help(client: Bot, msg: Message):
+ await client.send_message(
+ msg.chat.id,
+ "Cara Menggunakan Bot ini\n" + Data.HELP,
+ reply_markup=InlineKeyboardMarkup(Data.buttons),
+ )
@Bot.on_callback_query()
async def cb_handler(client: Bot, query: CallbackQuery):
data = query.data
if data == "about":
- await query.message.edit_text(
- text=f"Tentang Bot ini:\n\n@{client.username} adalah Bot Telegram untuk menyimpan Postingan atau File yang dapat Diakses melalui Link Khusus.\n\n • Creator: @{OWNER}\n • Source Code: File-Sharing-Man\n • Owner Repo: @mrismanaziz\n\n👨💻 Develoved by @Lunatic0de\n",
- disable_web_page_preview=True,
- reply_markup=InlineKeyboardMarkup(
- [[InlineKeyboardButton("• ᴛᴜᴛᴜᴘ •", callback_data="close")]]
- ),
- )
+ try:
+ await query.message.edit_text(
+ text=Data.ABOUT.format(client.username, OWNER),
+ disable_web_page_preview=True,
+ reply_markup=InlineKeyboardMarkup(Data.mbuttons),
+ )
+ except MessageNotModified:
+ pass
+ elif data == "help":
+ try:
+ await query.message.edit_text(
+ text="Cara Menggunakan Bot ini\n" + Data.HELP,
+ disable_web_page_preview=True,
+ reply_markup=InlineKeyboardMarkup(Data.buttons),
+ )
+ except MessageNotModified:
+ pass
elif data == "close":
await query.message.delete()
try:
diff --git a/plugins/channel_post.py b/plugins/channel_post.py
index ae016e80..f58ce6bc 100644
--- a/plugins/channel_post.py
+++ b/plugins/channel_post.py
@@ -9,7 +9,7 @@
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
from bot import Bot
-from config import ADMINS, CHANNEL_ID, DISABLE_CHANNEL_BUTTON
+from config import ADMINS, CHANNEL_ID, DISABLE_CHANNEL_BUTTON, LOGGER
from helper_func import encode
@@ -17,7 +17,23 @@
filters.private
& filters.user(ADMINS)
& ~filters.command(
- ["start", "users", "broadcast", "ping", "uptime", "batch", "genlink"]
+ [
+ "start",
+ "users",
+ "broadcast",
+ "ping",
+ "uptime",
+ "batch",
+ "logs",
+ "genlink",
+ "delvar",
+ "getvar",
+ "setvar",
+ "speedtest",
+ "update",
+ "stats",
+ "vars",
+ ]
)
)
async def channel_post(client: Client, message: Message):
@@ -32,7 +48,7 @@ async def channel_post(client: Client, message: Message):
chat_id=client.db_channel.id, disable_notification=True
)
except Exception as e:
- print(e)
+ LOGGER(__name__).warning(e)
await reply_text.edit_text("Telah Terjadi Error...")
return
converted_id = post_message.message_id * abs(client.db_channel.id)
@@ -84,4 +100,4 @@ async def new_post(client: Client, message: Message):
try:
await message.edit_reply_markup(reply_markup)
except Exception as e:
- print(e)
+ LOGGER(__name__).warning(e)
diff --git a/plugins/heroku.py b/plugins/heroku.py
new file mode 100644
index 00000000..8e906ab0
--- /dev/null
+++ b/plugins/heroku.py
@@ -0,0 +1,143 @@
+#
+# Copyright (C) 2021-2022 by TeamYukki@Github, < https://github.com/TeamYukki >.
+#
+# This file is part of < https://github.com/TeamYukki/YukkiMusicBot > project,
+# and is released under the "GNU v3.0 License Agreement".
+# Please see < https://github.com/TeamYukki/YukkiMusicBot/blob/master/LICENSE >
+#
+# All rights reserved.
+#
+# Ported by @mrismanaziz
+# FROM File-Sharing-Man < https://github.com/mrismanaziz/File-Sharing-Man/ >
+# t.me/Lunatic0de & t.me/SharingUserbot
+#
+
+import os
+import socket
+
+import dotenv
+import heroku3
+import urllib3
+from bot import Bot
+from config import ADMINS, HEROKU_API_KEY, HEROKU_APP_NAME
+from pyrogram import filters
+from pyrogram.types import Message
+
+urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
+if HEROKU_APP_NAME is not None and HEROKU_API_KEY is not None:
+ Heroku = heroku3.from_key(HEROKU_API_KEY)
+ HAPP = Heroku.app(HEROKU_APP_NAME)
+ heroku_config = HAPP.config()
+else:
+ HAPP = None
+
+XCB = [
+ "/",
+ "@",
+ ".",
+ "com",
+ ":",
+ "git",
+ "heroku",
+ "push",
+ str(HEROKU_API_KEY),
+ "https",
+ str(HEROKU_APP_NAME),
+ "HEAD",
+ "main",
+]
+
+
+async def is_heroku():
+ return "heroku" in socket.getfqdn()
+
+
+@Bot.on_message(filters.command("getvar") & filters.user(ADMINS))
+async def varget_(client: Bot, message: Message):
+ if len(message.command) != 2:
+ return await message.reply_text("Usage:\n/getvar [Var Name]")
+ check_var = message.text.split(None, 2)[1]
+ if await is_heroku():
+ if HAPP is None:
+ return await message.reply_text(
+ "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:
+ return await message.reply_text(
+ f"{check_var}: {heroku_config[check_var]}
"
+ )
+ else:
+ return await message.reply_text(f"Tidak dapat menemukan var {check_var}")
+ else:
+ 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:
+ return await message.reply_text(
+ f"{check_var}: {str(output)}
"
+ )
+
+
+@Bot.on_message(filters.command("delvar") & filters.user(ADMINS))
+async def vardel_(client: Bot, message: Message):
+ if len(message.command) != 2:
+ return await message.reply_text("Usage:\n/delvar [Var Name]")
+ check_var = message.text.split(None, 2)[1]
+ if await is_heroku():
+ if HAPP is None:
+ return await message.reply_text(
+ "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:
+ return await message.reply_text(f"Tidak dapat menemukan var {check_var}")
+ 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")
+
+
+@Bot.on_message(filters.command("setvar") & filters.user(ADMINS))
+async def set_var(client: Bot, message: Message):
+ if len(message.command) < 3:
+ return await message.reply_text("Usage:\n/setvar [Var Name] [Var Value]")
+ to_set = message.text.split(None, 2)[1].strip()
+ value = message.text.split(None, 2)[2].strip()
+ if await is_heroku():
+ if HAPP is None:
+ return await message.reply_text(
+ "Pastikan HEROKU_API_KEY dan HEROKU_APP_NAME anda dikonfigurasi dengan benar di config vars heroku"
+ )
+ heroku_config = HAPP.config()
+ if to_set in heroku_config:
+ await message.reply_text(f"Berhasil Mengubah var {to_set} menjadi {value}")
+ else:
+ await message.reply_text(
+ f"Berhasil Menambahkan var {to_set} menjadi {value}"
+ )
+ heroku_config[to_set] = value
+ else:
+ path = dotenv.find_dotenv("config.env")
+ if not path:
+ return await message.reply_text(".env file not found.")
+ dotenv.set_key(path, to_set, value)
+ if dotenv.get_key(path, to_set):
+ await message.reply_text(f"Berhasil Mengubah var {to_set} menjadi {value}")
+ else:
+ await message.reply_text(
+ f"Berhasil Menambahkan var {to_set} menjadi {value}"
+ )
+ os.system(f"kill -9 {os.getpid()} && bash start")
diff --git a/plugins/speedtest.py b/plugins/speedtest.py
new file mode 100644
index 00000000..ff9898c5
--- /dev/null
+++ b/plugins/speedtest.py
@@ -0,0 +1,59 @@
+#
+# Copyright (C) 2021-2022 by TeamYukki@Github, < https://github.com/TeamYukki >.
+#
+# This file is part of < https://github.com/TeamYukki/YukkiMusicBot > project,
+# and is released under the "GNU v3.0 License Agreement".
+# Please see < https://github.com/TeamYukki/YukkiMusicBot/blob/master/LICENSE >
+#
+# All rights reserved.
+#
+# Ported by @mrismanaziz
+# FROM File-Sharing-Man < https://github.com/mrismanaziz/File-Sharing-Man/ >
+# t.me/Lunatic0de & t.me/SharingUserbot
+#
+
+import os
+
+import speedtest
+import wget
+from pyrogram import filters
+from pyrogram.types import Message
+
+from bot import Bot
+from config import ADMINS
+
+
+@Bot.on_message(filters.command("speedtest") & filters.user(ADMINS))
+async def run_speedtest(client: Bot, message: Message):
+ m = await message.reply_text("⚡️ Running Server Speedtest")
+ try:
+ test = speedtest.Speedtest()
+ test.get_best_server()
+ m = await m.edit("⚡️ Running Download Speedtest..")
+ test.download()
+ m = await m.edit("⚡️ Running Upload Speedtest...")
+ test.upload()
+ test.results.share()
+ result = test.results.dict()
+ except Exception as e:
+ await m.edit(e)
+ return
+ m = await m.edit("🔄 Sharing Speedtest Results")
+ path = wget.download(result["share"])
+
+ output = f"""💡 SpeedTest Results
+
+Client:
+ISP: {result['client']['isp']}
+Country: {result['client']['country']}
+
+Server:
+Name: {result['server']['name']}
+Country: {result['server']['country']}, {result['server']['cc']}
+Sponsor: {result['server']['sponsor']}
+⚡️ Ping: {result['ping']}"""
+ msg = await client.send_photo(
+ chat_id=message.chat.id, photo=path, caption=output
+ )
+ os.remove(path)
+ await m.delete()
diff --git a/plugins/start.py b/plugins/start.py
index 2de0bccf..70f2cf2d 100644
--- a/plugins/start.py
+++ b/plugins/start.py
@@ -6,22 +6,30 @@
from datetime import datetime
from time import time
-from pyrogram import Client, filters
-from pyrogram.errors import FloodWait, InputUserDeactivated, UserIsBlocked
-from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
-
from bot import Bot
-from .button import fsub_button, start_button
-from config import ADMINS, CUSTOM_CAPTION, DISABLE_CHANNEL_BUTTON, FORCE_MSG, START_MSG
+from config import (
+ ADMINS,
+ CUSTOM_CAPTION,
+ DISABLE_CHANNEL_BUTTON,
+ FORCE_MSG,
+ PROTECT_CONTENT,
+ START_MSG,
+)
from database.sql import add_user, full_userbase, query_msg
+from pyrogram import filters
+from pyrogram.errors import FloodWait, InputUserDeactivated, UserIsBlocked
+from pyrogram.types import InlineKeyboardMarkup, Message
+
from helper_func import decode, get_messages, subsall, subsch, subsgc
+from .button import fsub_button, start_button
+
START_TIME = datetime.utcnow()
START_TIME_ISO = START_TIME.replace(microsecond=0).isoformat()
TIME_DURATION_UNITS = (
("week", 60 * 60 * 24 * 7),
- ("day", 60 ** 2 * 24),
- ("hour", 60 ** 2),
+ ("day", 60**2 * 24),
+ ("hour", 60**2),
("min", 60),
("sec", 1),
)
@@ -34,14 +42,19 @@ async def _human_time_duration(seconds):
for unit, div in TIME_DURATION_UNITS:
amount, seconds = divmod(int(seconds), div)
if amount > 0:
- parts.append("{} {}{}".format(amount, unit, "" if amount == 1 else "s"))
+ parts.append(f'{amount} {unit}{"" if amount == 1 else "s"}')
return ", ".join(parts)
@Bot.on_message(filters.command("start") & filters.private & subsall & subsch & subsgc)
async def start_command(client: Bot, message: Message):
id = message.from_user.id
- user_name = "@" + message.from_user.username if message.from_user.username else None
+ user_name = (
+ f"@{message.from_user.username}"
+ if message.from_user.username
+ else None
+ )
+
try:
await add_user(id, user_name)
except:
@@ -87,11 +100,12 @@ async def start_command(client: Bot, message: Message):
if bool(CUSTOM_CAPTION) & bool(msg.document):
caption = CUSTOM_CAPTION.format(
- previouscaption="" if not msg.caption else msg.caption.html,
+ previouscaption=msg.caption.html if msg.caption else "",
filename=msg.document.file_name,
)
+
else:
- caption = "" if not msg.caption else msg.caption.html
+ caption = msg.caption.html if msg.caption else ""
reply_markup = msg.reply_markup if DISABLE_CHANNEL_BUTTON else None
try:
@@ -99,6 +113,7 @@ async def start_command(client: Bot, message: Message):
chat_id=message.from_user.id,
caption=caption,
parse_mode="html",
+ protect_content=PROTECT_CONTENT,
reply_markup=reply_markup,
)
await asyncio.sleep(0.5)
@@ -108,6 +123,7 @@ async def start_command(client: Bot, message: Message):
chat_id=message.from_user.id,
caption=caption,
parse_mode="html",
+ protect_content=PROTECT_CONTENT,
reply_markup=reply_markup,
)
except BaseException:
@@ -118,9 +134,9 @@ async def start_command(client: Bot, message: Message):
text=START_MSG.format(
first=message.from_user.first_name,
last=message.from_user.last_name,
- username=None
- if not message.from_user.username
- else "@" + message.from_user.username,
+ username=f"@{message.from_user.username}"
+ if message.from_user.username
+ else None,
mention=message.from_user.mention,
id=message.from_user.id,
),
@@ -129,6 +145,7 @@ async def start_command(client: Bot, message: Message):
quote=True,
)
+
return
@@ -139,9 +156,9 @@ async def not_joined(client: Bot, message: Message):
text=FORCE_MSG.format(
first=message.from_user.first_name,
last=message.from_user.last_name,
- username=None
- if not message.from_user.username
- else "@" + message.from_user.username,
+ username=f"@{message.from_user.username}"
+ if message.from_user.username
+ else None,
mention=message.from_user.mention,
id=message.from_user.id,
),
@@ -178,11 +195,11 @@ async def send_text(client: Bot, message: Message):
chat_id = int(row[0])
if chat_id not in ADMINS:
try:
- await broadcast_msg.copy(chat_id)
+ await broadcast_msg.copy(chat_id, protect_content=PROTECT_CONTENT)
successful += 1
except FloodWait as e:
await asyncio.sleep(e.x)
- await broadcast_msg.copy(chat_id)
+ await broadcast_msg.copy(chat_id, protect_content=PROTECT_CONTENT)
successful += 1
except UserIsBlocked:
blocked += 1
diff --git a/plugins/updater.py b/plugins/updater.py
new file mode 100644
index 00000000..ebee9814
--- /dev/null
+++ b/plugins/updater.py
@@ -0,0 +1,84 @@
+# Credits: @mrismanaziz
+# FROM File-Sharing-Man
+# t.me/SharingUserbot & t.me/Lunatic0de
+
+import os
+import sys
+from os import environ, execle, system
+
+from git import Repo
+from git.exc import InvalidGitRepositoryError
+from pyrogram import Client, filters
+from pyrogram.types import Message
+
+from config import LOGGER
+
+UPSTREAM_REPO = "https://github.com/mrismanaziz/File-Sharing-Man"
+
+
+def gen_chlog(repo, diff):
+ upstream_repo_url = Repo().remotes[0].config_reader.get("url").replace(".git", "")
+ ac_br = repo.active_branch.name
+ ch_log = ""
+ tldr_log = ""
+ ch = f"updates for [{ac_br}]:"
+ ch_tl = f"updates for {ac_br}:"
+ d_form = "%d/%m/%y || %H:%M"
+ for c in repo.iter_commits(diff):
+ ch_log += (
+ f"\n\n💬 {c.count()} 🗓 [{c.committed_datetime.strftime(d_form)}]\n"
+ f"[{c.summary}] 👨💻 {c.author}
"
+ )
+ tldr_log += f"\n\n💬 {c.count()} 🗓 [{c.committed_datetime.strftime(d_form)}]\n[{c.summary}] 👨💻 {c.author}"
+ if ch_log:
+ return str(ch + ch_log), str(ch_tl + tldr_log)
+ return ch_log, tldr_log
+
+
+def updater():
+ try:
+ repo = Repo()
+ except InvalidGitRepositoryError:
+ repo = Repo.init()
+ origin = repo.create_remote("upstream", UPSTREAM_REPO)
+ origin.fetch()
+ repo.create_head("master", origin.refs.master)
+ repo.heads.master.set_tracking_branch(origin.refs.master)
+ repo.heads.master.checkout(True)
+ ac_br = repo.active_branch.name
+ if "upstream" in repo.remotes:
+ ups_rem = repo.remote("upstream")
+ else:
+ ups_rem = repo.create_remote("upstream", UPSTREAM_REPO)
+ ups_rem.fetch(ac_br)
+ changelog, tl_chnglog = gen_chlog(repo, f"HEAD..upstream/{ac_br}")
+ return bool(changelog)
+
+
+
+@Bot.on_message(filters.command("update") & filters.user(ADMINS))
+async def update_bot(_, message: Message):
+ message.chat.id
+ msg = await message.reply_text("Checking updates...")
+ update_avail = updater()
+ if update_avail:
+ 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)
+ return
+ await msg.edit(
+ f"Bot is **up-to-date** with branch [master]({UPSTREAM_REPO}/tree/master)",
+ disable_web_page_preview=True,
+ )
+
+
+@Bot.on_message(filters.command("restart") & filters.user(ADMINS))
+async def restart_bot(_, message: Message):
+ try:
+ msg = await message.reply_text("`Restarting bot...`")
+ LOGGER(__name__).info("BOT SERVER RESTARTED !!")
+ except BaseException as err:
+ LOGGER(__name__).info(f"{err}")
+ return
+ await msg.edit_text("✅ Bot has restarted !\n\n")
+ os.system(f"kill -9 {os.getpid()} && bash start")
diff --git a/plugins/utils.py b/plugins/utils.py
new file mode 100644
index 00000000..2f7d94f4
--- /dev/null
+++ b/plugins/utils.py
@@ -0,0 +1,69 @@
+# Credits: @mrismanaziz
+# FROM File-Sharing-Man
+# t.me/SharingUserbot & t.me/Lunatic0de
+
+import os
+
+from bot import Bot
+from config import (
+ ADMINS,
+ API_HASH,
+ APP_ID,
+ CHANNEL_ID,
+ DB_URI,
+ FORCE_MSG,
+ FORCE_SUB_CHANNEL,
+ FORCE_SUB_GROUP,
+ HEROKU_API_KEY,
+ HEROKU_APP_NAME,
+ LOGGER,
+ OWNER,
+ PROTECT_CONTENT,
+ START_MSG,
+ TG_BOT_TOKEN,
+)
+from pyrogram import filters
+from pyrogram.types import Message
+
+
+@Bot.on_message(filters.command("logs") & filters.user(ADMINS))
+async def get_bot_logs(client: Bot, m: Message):
+ bot_log_path = "logs.txt"
+ if os.path.exists(bot_log_path):
+ try:
+ await m.reply_document(
+ bot_log_path,
+ quote=True,
+ caption="Ini Logs Bot ini",
+ )
+ except Exception as e:
+ os.remove(bot_log_path)
+ LOGGER(__name__).warning(e)
+ elif not os.path.exists(bot_log_path):
+ await m.reply_text("❌ Tidak ada log yang ditemukan!")
+
+
+@Bot.on_message(filters.command("vars") & filters.user(ADMINS))
+async def varsFunc(client: Bot, message: Message):
+ Man = await message.reply_text("Tunggu Sebentar...")
+ text = f"""CONFIG VARS @{client.username}
+APP_ID = {APP_ID}
+API_HASH = {API_HASH}
+TG_BOT_TOKEN = {TG_BOT_TOKEN}
+DATABASE_URL = {DB_URI}
+OWNER = {OWNER}
+ADMINS = {ADMINS}
+
+CUSTOM VARS
+CHANNEL_ID = {CHANNEL_ID}
+FORCE_SUB_CHANNEL = {FORCE_SUB_CHANNEL}
+FORCE_SUB_GROUP = {FORCE_SUB_GROUP}
+PROTECT_CONTENT = {PROTECT_CONTENT}
+START_MSG = {START_MSG}
+FORCE_MSG = {FORCE_MSG}
+
+HEROKU CONFIGVARS
+HEROKU_APP_NAME = {HEROKU_APP_NAME}
+HEROKU_API_KEY = {HEROKU_API_KEY}
+ """
+ await Man.edit_text(text)
diff --git a/requirements.txt b/requirements.txt
index 631f230d..0e9f6b09 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,11 @@
feedparser
+gitpython
+heroku3
psycopg2-binary
pyrogram==1.4.16
python-dotenv
Pyromod
+speedtest-cli
sqlalchemy==1.3.23
TgCrypto
+wget
diff --git a/runtime.txt b/runtime.txt
index 54029619..c6f7782f 100644
--- a/runtime.txt
+++ b/runtime.txt
@@ -1 +1 @@
-python-3.9.12
+python-3.9.13
diff --git a/sample_config.env b/sample_config.env
index 1b7a503a..54cba8fb 100644
--- a/sample_config.env
+++ b/sample_config.env
@@ -5,7 +5,7 @@ APP_ID = "6"
API_HASH = "eb06d4abfb49dc3eeb1aeb98ae0f581e"
# Masukan BOT TOKEN dari @botfather
-TG_BOT_TOKEN = "10010102:2abcdefghij"
+TG_BOT_TOKEN = "10010102:2abcdefghijklmnopqrstuvwxyz"
# Masukan User ID untuk hak ADMINS bot
ADMINS = "1234567890"
@@ -14,7 +14,7 @@ ADMINS = "1234567890"
OWNER = "mrismanaziz"
# Masukan User id untuk hak owner
-OWNER_ID = "1234567890"
+OWNER_ID = "844432220"
# Masukan Chat ID dari Group Untuk Wajib Subscribenya
# Bila tidak ingin dipakai Fsubnya, isi dengan 0
@@ -30,3 +30,9 @@ CHANNEL_ID = -100
# URL Database Anda, Ambil dari https://elephantsql.com
# Contoh: "postgres://userbot:userbot@localhost:5432/userbot"
DATABASE_URL = ""
+
+# Fitur PROTECT_CONTENT adalah Untuk MENCEGAH pengguna bot untuk mendownload/memforward/mengscreenshot konten yang dikirim di bot
+# Untuk Mengaktifkan PROTECT_CONTENT Ubah ke True
+# Untuk Menonaktifkan PROTECT_CONTENT Ubah ke False
+PROTECT_CONTENT = False
+
diff --git a/start b/start
index eb7516bd..2e5eeafa 100644
--- a/start
+++ b/start
@@ -1 +1,15 @@
+#!/usr/bin/bash
+#
+# Credits: @mrismanaziz
+# FROM File-Sharing-Man
+# t.me/SharingUserbot & t.me/Lunatic0de
+
+# Attemp to Terminate and Remove previous session
+if [ ! -d .git ]; then
+ git clone https://github.com/mrismanaziz/File-Sharing-Man -b master tmp_git
+ mv tmp_git/.git .
+ rm -rf tmp_git
+fi
+
+# start
python3 main.py