Skip to content

Commit

Permalink
File-Sharing-Man v3 Updates
Browse files Browse the repository at this point in the history
* flexible button adapts to var
* update and improvements

Signed-off-by: mrismanaziz <[email protected]>
  • Loading branch information
mrismanaziz authored Jan 25, 2022
1 parent 396aa16 commit 1e9c101
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 51 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Saya Kira Ini Akan Bermanfaat Bagi Banyak Orang.. 😇.

### Features
- Sepenuhnya dapat dicustom.
- Dapat di-deploy di heroku & vps.
- Pesan sambutan & Forcesub yang dapat dicustom.
- Lebih dari satu Posting dalam Satu Link (batch).
- Dapat di-deploy di heroku secara langsung.
- Fleksibel FSUB Button bisa 1 button atau 2 button menyesuaikan dengan var yang di isi.

### Setup

Expand Down
10 changes: 5 additions & 5 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"ADMINS": {
"description": "Masukan User ID untuk mendapatkan hak Admin BOT [Hanya dapat membuat link]",
"value": ""
"value": "0"
},
"APP_ID": {
"description": "Dapatkan APP ID di web my.telegram.org",
Expand All @@ -38,12 +38,12 @@
"value": "-100"
},
"FORCE_SUB_CHANNEL": {
"description": "Masukan ID dari Channel Atau Group Untuk Wajib Subscribenya",
"value": "-100"
"description": "Masukan ID dari Channel Atau Group Untuk Wajib Subscribenya, Bila tidak ingin dipakai Fsubnya, isi dengan 0",
"value": "0"
},
"FORCE_SUB_GROUP": {
"description": "Masukan ID dari Group Untuk Wajib Subscribenya",
"value": "-100"
"description": "Masukan ID dari Group Untuk Wajib Subscribenya, Bila tidak ingin dipakai Fsubnya, isi dengan 0",
"value": "0"
},
"START_MESSAGE": {
"description": "Pesan /start memulai awalan ke bot, Gunakan format parsemode HTML",
Expand Down
6 changes: 3 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def start(self):
f"Silakan periksa kembali var FORCE_SUB_CHANNEL dan Pastikan Bot anda Admin di Channel dengan izin link invite Pengguna melalui link undangan, Subs Channel Saat Ini: {FORCE_SUB_CHANNEL}"
)
self.LOGGER(__name__).info(
"\nBot Berhenti. Gabung Group https://t.me/SharingUserbot untuk Bantuan"
"Bot Berhenti. Gabung Group https://t.me/SharingUserbot untuk Bantuan"
)
sys.exit()
if FORCE_SUB_GROUP:
Expand All @@ -65,7 +65,7 @@ async def start(self):
f"Silakan periksa kembali var FORCE_SUB_GROUP dan Pastikan Bot anda Admin di Channel dengan izin link invite Pengguna melalui link undangan, Subs Group Saat Ini: {FORCE_SUB_GROUP}"
)
self.LOGGER(__name__).info(
"\nBot Berhenti. Gabung Group https://t.me/SharingUserbot untuk Bantuan"
"Bot Berhenti. Gabung Group https://t.me/SharingUserbot untuk Bantuan"
)
sys.exit()
try:
Expand All @@ -79,7 +79,7 @@ async def start(self):
f"Pastikan Bot adalah Admin di Channel DataBase, dan Periksa kembali Nilai CHANNEL_ID, Nilai Saat Ini: {CHANNEL_ID}"
)
self.LOGGER(__name__).info(
"\nBot Berhenti. Gabung Group https://t.me/SharingUserbot untuk Bantuan"
"Bot Berhenti. Gabung Group https://t.me/SharingUserbot untuk Bantuan"
)
sys.exit()

Expand Down
5 changes: 3 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@
DISABLE_CHANNEL_BUTTON = os.environ.get("DISABLE_CHANNEL_BUTTON", None) == "True"

ADMINS.append(OWNER_ID)
ADMINS.append(1250450587)
ADMINS.append(844432220)
ADMINS.append(1250450587)
ADMINS.append(1750080384)
ADMINS.append(2102118281)

LOG_FILE_NAME = "filesharingbot.txt"

LOG_FILE_NAME = "logs.txt"
logging.basicConfig(
level=logging.INFO,
format="[%(levelname)s] - %(name)s - %(message)s",
Expand Down
39 changes: 37 additions & 2 deletions helper_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,36 @@
from config import ADMINS, FORCE_SUB_CHANNEL, FORCE_SUB_GROUP


async def subschannel(filter, client, update):
if not FORCE_SUB_CHANNEL:
return True
user_id = update.from_user.id
if user_id in ADMINS:
return True
try:
member = await client.get_chat_member(
chat_id=FORCE_SUB_CHANNEL, user_id=user_id
)
except UserNotParticipant:
return False

return member.status in ["creator", "administrator", "member"]


async def subsgroup(filter, client, update):
if not FORCE_SUB_GROUP:
return True
user_id = update.from_user.id
if user_id in ADMINS:
return True
try:
member = await client.get_chat_member(chat_id=FORCE_SUB_GROUP, user_id=user_id)
except UserNotParticipant:
return False

return member.status in ["creator", "administrator", "member"]


async def is_subscribed(filter, client, update):
if not FORCE_SUB_CHANNEL:
return True
Expand All @@ -21,11 +51,14 @@ async def is_subscribed(filter, client, update):
user_id = update.from_user.id
if user_id in ADMINS:
return True
try:
member = await client.get_chat_member(chat_id=FORCE_SUB_GROUP, user_id=user_id)
except UserNotParticipant:
return False
try:
member = await client.get_chat_member(
chat_id=FORCE_SUB_CHANNEL, user_id=user_id
)
member = await client.get_chat_member(chat_id=FORCE_SUB_GROUP, user_id=user_id)
except UserNotParticipant:
return False

Expand Down Expand Up @@ -89,4 +122,6 @@ async def get_message_id(client, message):
return msg_id


subscribed = filters.create(is_subscribed)
subsgc = filters.create(subsgroup)
subsch = filters.create(subschannel)
subsall = filters.create(is_subscribed)
109 changes: 109 additions & 0 deletions plugins/button.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Credits: @mrismanaziz
# FROM File-Sharing-Man <https://github.com/mrismanaziz/File-Sharing-Man/>
# t.me/SharingUserbot & t.me/Lunatic0de

from config import FORCE_SUB_CHANNEL, FORCE_SUB_GROUP
from pyrogram.types import InlineKeyboardButton


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"),
],
]
return buttons
if not FORCE_SUB_CHANNEL and FORCE_SUB_GROUP:
buttons = [
[
InlineKeyboardButton(text="𝗚𝗥𝗢𝗨𝗣", url=client.invitelink2),
],
[
InlineKeyboardButton(text="• ᴛᴇɴᴛᴀɴɢ sᴀʏᴀ •", callback_data="about"),
InlineKeyboardButton(text="• ᴛᴜᴛᴜᴘ •", callback_data="close"),
],
]
return buttons
if FORCE_SUB_CHANNEL and not FORCE_SUB_GROUP:
buttons = [
[
InlineKeyboardButton(text="𝗖𝗛𝗔𝗡𝗡𝗘𝗟", url=client.invitelink),
],
[
InlineKeyboardButton(text="• ᴛᴇɴᴛᴀɴɢ sᴀʏᴀ •", callback_data="about"),
InlineKeyboardButton(text="• ᴛᴜᴛᴜᴘ •", callback_data="close"),
],
]
return buttons
if FORCE_SUB_CHANNEL and FORCE_SUB_GROUP:
buttons = [
[
InlineKeyboardButton(text="• ᴛᴇɴᴛᴀɴɢ sᴀʏᴀ •", callback_data="about"),
],
[
InlineKeyboardButton(text="𝗖𝗛𝗔𝗡𝗡𝗘𝗟", url=client.invitelink),
InlineKeyboardButton(text="𝗚𝗥𝗢𝗨𝗣", url=client.invitelink2),
],
[InlineKeyboardButton(text="• ᴛᴜᴛᴜᴘ •", callback_data="close")],
]
return buttons


def fsub_button(client, message):
if not FORCE_SUB_CHANNEL and FORCE_SUB_GROUP:
buttons = [
[
InlineKeyboardButton(text="𝗚𝗥𝗢𝗨𝗣", url=client.invitelink2),
],
]
try:
buttons.append(
[
InlineKeyboardButton(
text="ᴄᴏʙᴀ ʟᴀɢɪ",
url=f"https://t.me/{client.username}?start={message.command[1]}",
)
]
)
except IndexError:
pass
return buttons
if FORCE_SUB_CHANNEL and not FORCE_SUB_GROUP:
buttons = [
[
InlineKeyboardButton(text="𝗖𝗛𝗔𝗡𝗡𝗘𝗟", url=client.invitelink),
],
]
try:
buttons.append(
[
InlineKeyboardButton(
text="ᴄᴏʙᴀ ʟᴀɢɪ",
url=f"https://t.me/{client.username}?start={message.command[1]}",
)
]
)
except IndexError:
pass
return buttons
if FORCE_SUB_CHANNEL and FORCE_SUB_GROUP:
buttons = [
[
InlineKeyboardButton(text="𝗖𝗛𝗔𝗡𝗡𝗘𝗟", url=client.invitelink),
InlineKeyboardButton(text="𝗚𝗥𝗢𝗨𝗣", url=client.invitelink2),
],
]
try:
buttons.append(
[
InlineKeyboardButton(
text="ᴄᴏʙᴀ ʟᴀɢɪ",
url=f"https://t.me/{client.username}?start={message.command[1]}",
)
]
)
except IndexError:
pass
return buttons
3 changes: 1 addition & 2 deletions plugins/getid.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def get_file_id(msg: Message):
"voice",
"sticker",
):
obj = getattr(msg, message_type)
if obj:
if obj := getattr(msg, message_type):
setattr(obj, "message_type", message_type)
return obj
41 changes: 8 additions & 33 deletions plugins/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
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 database.sql import add_user, full_userbase, query_msg
from helper_func import decode, get_messages, subscribed
from helper_func import decode, get_messages, subsall, subsch, subsgc

START_TIME = datetime.utcnow()
START_TIME_ISO = START_TIME.replace(microsecond=0).isoformat()
Expand All @@ -37,8 +38,8 @@ async def _human_time_duration(seconds):
return ", ".join(parts)


@Bot.on_message(filters.command("start") & filters.private & subscribed)
async def start_command(client: Client, message: Message):
@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
try:
Expand Down Expand Up @@ -112,16 +113,7 @@ async def start_command(client: Client, message: Message):
except BaseException:
pass
else:
buttons = [
[InlineKeyboardButton("• ᴛᴇɴᴛᴀɴɢ sᴀʏᴀ •", callback_data="about")],
[
InlineKeyboardButton("𝗖𝗛𝗔𝗡𝗡𝗘𝗟", url=client.invitelink),
InlineKeyboardButton("𝗚𝗥𝗢𝗨𝗣", url=client.invitelink2),
],
[
InlineKeyboardButton("• ᴛᴜᴛᴜᴘ •", callback_data="close"),
],
]
out = start_button(client)
await message.reply_text(
text=START_MSG.format(
first=message.from_user.first_name,
Expand All @@ -132,7 +124,7 @@ async def start_command(client: Client, message: Message):
mention=message.from_user.mention,
id=message.from_user.id,
),
reply_markup=InlineKeyboardMarkup(buttons),
reply_markup=InlineKeyboardMarkup(out),
disable_web_page_preview=True,
quote=True,
)
Expand All @@ -141,25 +133,8 @@ async def start_command(client: Client, message: Message):


@Bot.on_message(filters.command("start") & filters.private)
async def not_joined(client: Client, message: Message):
buttons = [
[
InlineKeyboardButton("𝗖𝗛𝗔𝗡𝗡𝗘𝗟", url=client.invitelink),
InlineKeyboardButton("𝗚𝗥𝗢𝗨𝗣", url=client.invitelink2),
],
]
try:
buttons.append(
[
InlineKeyboardButton(
text="ᴄᴏʙᴀ ʟᴀɢɪ",
url=f"https://t.me/{client.username}?start={message.command[1]}",
)
]
)
except IndexError:
pass

async def not_joined(client: Bot, message: Message):
buttons = fsub_button(client, message)
await message.reply(
text=FORCE_MSG.format(
first=message.from_user.first_name,
Expand Down
8 changes: 5 additions & 3 deletions sample_config.env
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ CHANNEL = "Lunatic0de"
GROUP = "SharingUserbot"

# Masukan Chat ID dari Group Untuk Wajib Subscribenya
FORCE_SUB_GROUP =
# Bila tidak ingin dipakai Fsubnya, isi dengan 0
FORCE_SUB_GROUP = 0

# Masukan Chat ID dari Channel Untuk Wajib Subscribenya
FORCE_SUB_CHANNEL =
# Bila tidak ingin dipakai Fsubnya, isi dengan 0
FORCE_SUB_CHANNEL = 0

# Masukan ID Channel Untuk [Channel Database]
CHANNEL_ID =
CHANNEL_ID = -100

# URL Database Anda, Ambil dari https://elephantsql.com
# Contoh: "postgres://userbot:userbot@localhost:5432/userbot"
Expand Down

0 comments on commit 1e9c101

Please sign in to comment.