BinaryONe
commited on
Commit
·
c96bd11
1
Parent(s):
26b0c4e
changes In Upload
Browse files
FileStream/bot/plugins/FileHandlers/callback.py
CHANGED
@@ -2,7 +2,7 @@ import math
|
|
2 |
import asyncio
|
3 |
import datetime
|
4 |
|
5 |
-
from pyrogram import filters, Client
|
6 |
from pyrogram.errors import FloodWait
|
7 |
from pyrogram.enums.parse_mode import ParseMode
|
8 |
from pyrogram.file_id import FileId, FileType, PHOTO_TYPES
|
@@ -102,7 +102,7 @@ async def cb_data(bot: Client, update: CallbackQuery):
|
|
102 |
disable_web_page_preview=True,
|
103 |
reply_markup=reply_markup,
|
104 |
)
|
105 |
-
elif usr_cmd[0] == "
|
106 |
try:
|
107 |
user_id = str(usr_cmd[1])
|
108 |
message_id = int(usr_cmd[2])
|
@@ -115,7 +115,41 @@ async def cb_data(bot: Client, update: CallbackQuery):
|
|
115 |
file_caption = getattr(message, "caption", f"{get_name(message)}" ) or "None/Unknown"
|
116 |
file_name = get_name(message)
|
117 |
print("Daetail",file_caption,file_name)
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
print(polls)
|
120 |
file_info = get_file_info(message, instruction)
|
121 |
# Here we are Adding the File Into the database First
|
@@ -129,7 +163,7 @@ async def cb_data(bot: Client, update: CallbackQuery):
|
|
129 |
parse_mode=ParseMode.HTML,
|
130 |
disable_web_page_preview=True,
|
131 |
reply_markup=reply_markup,
|
132 |
-
)
|
133 |
except FloodWait as e:
|
134 |
print(f"Sleeping for {str(e.value)}s")
|
135 |
await asyncio.sleep(e.value)
|
|
|
2 |
import asyncio
|
3 |
import datetime
|
4 |
|
5 |
+
from pyrogram import filters, Client,raw, types
|
6 |
from pyrogram.errors import FloodWait
|
7 |
from pyrogram.enums.parse_mode import ParseMode
|
8 |
from pyrogram.file_id import FileId, FileType, PHOTO_TYPES
|
|
|
102 |
disable_web_page_preview=True,
|
103 |
reply_markup=reply_markup,
|
104 |
)
|
105 |
+
elif usr_cmd[0] == "initilize":
|
106 |
try:
|
107 |
user_id = str(usr_cmd[1])
|
108 |
message_id = int(usr_cmd[2])
|
|
|
115 |
file_caption = getattr(message, "caption", f"{get_name(message)}" ) or "None/Unknown"
|
116 |
file_name = get_name(message)
|
117 |
print("Daetail",file_caption,file_name)
|
118 |
+
await FileStream.send_poll(user_id, "Is this a poll question?", ["Yes", "No", "Maybe"])
|
119 |
+
#print(polls)
|
120 |
+
|
121 |
+
except Exception as e:
|
122 |
+
print(f"An error occurred: {str(e)}")
|
123 |
+
await FileStream.send_message(
|
124 |
+
chat_id=Telegram.ULOG_GROUP,
|
125 |
+
text=f"An error occurred: {str(e)}"
|
126 |
+
)
|
127 |
+
|
128 |
+
elif usr_cmd[0] == "pubup":
|
129 |
+
try:
|
130 |
+
user_id = str(usr_cmd[1])
|
131 |
+
message_id = int(usr_cmd[2])
|
132 |
+
message = await FileStream.get_messages(user_id, message_id)
|
133 |
+
instruction = {
|
134 |
+
"privacy_type": "PUBLIC",
|
135 |
+
"user_id": user_id,
|
136 |
+
"user_type": "TELEGRAM"
|
137 |
+
}
|
138 |
+
file_caption = getattr(message, "caption", f"{get_name(message)}" ) or "None/Unknown"
|
139 |
+
file_name = get_name(message)
|
140 |
+
print("Daetail",file_caption,"\nFile:",file_name)
|
141 |
+
new_question = file_caption
|
142 |
+
new_options = ["Yes", "No", "Maybe"]
|
143 |
+
poll = raw.types.InputMediaPoll(
|
144 |
+
poll=raw.types.Poll(
|
145 |
+
id=client.rnd_id(),
|
146 |
+
question=new_question,
|
147 |
+
answers=[raw.types.PollAnswer(text=text, option=bytes([i])) for i, text in enumerate(new_options)]
|
148 |
+
)
|
149 |
+
)
|
150 |
+
await FileStream.edit_message_media(chat_id, message_id, media=poll)
|
151 |
+
|
152 |
+
"""
|
153 |
print(polls)
|
154 |
file_info = get_file_info(message, instruction)
|
155 |
# Here we are Adding the File Into the database First
|
|
|
163 |
parse_mode=ParseMode.HTML,
|
164 |
disable_web_page_preview=True,
|
165 |
reply_markup=reply_markup,
|
166 |
+
)"""
|
167 |
except FloodWait as e:
|
168 |
print(f"Sleeping for {str(e.value)}s")
|
169 |
await asyncio.sleep(e.value)
|
FileStream/bot/plugins/FileHandlers/polls.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from FileStream.bot import FileStream
|
2 |
+
|
3 |
+
|
4 |
+
@FileStream.on_poll()
|
5 |
+
def handle_poll(FileStream, poll):
|
6 |
+
print(f"Poll ID: {poll.id}")
|
7 |
+
print(f"Question: {poll.question}")
|
8 |
+
print(f"Options: {poll.options}")
|
9 |
+
print(f"Total Voters: {poll.total_voter_count}")
|
10 |
+
#app.loop.create_task(poll_handler(client, poll))
|
FileStream/bot/plugins/FileHandlers/stream.py
CHANGED
@@ -124,7 +124,6 @@ async def reply_handler(
|
|
124 |
message: Message,
|
125 |
thumb: Union[str, BinaryIO] = None,
|
126 |
):
|
127 |
-
|
128 |
replied_message = message.reply_to_message
|
129 |
resp = ["n", "no", "not"]
|
130 |
if not replied_message:
|
@@ -172,11 +171,9 @@ async def reply_handler(
|
|
172 |
file_name=file_info['file']['file_name'],
|
173 |
file_size=file_info['file']['file_size'],
|
174 |
progress=progress,
|
175 |
-
progress_args=(replied_message, file_info['file']['file_name'],
|
176 |
-
file_info['file']['file_size'], start_time))
|
177 |
|
178 |
-
success_text = LANG.SUCCESS_PRIV_FILE.format(
|
179 |
-
file_info['file']['file_name'], humanbytes(file_size))
|
180 |
await replied_message.edit_text(
|
181 |
text=success_text,
|
182 |
parse_mode=ParseMode.HTML,
|
|
|
124 |
message: Message,
|
125 |
thumb: Union[str, BinaryIO] = None,
|
126 |
):
|
|
|
127 |
replied_message = message.reply_to_message
|
128 |
resp = ["n", "no", "not"]
|
129 |
if not replied_message:
|
|
|
171 |
file_name=file_info['file']['file_name'],
|
172 |
file_size=file_info['file']['file_size'],
|
173 |
progress=progress,
|
174 |
+
progress_args=(replied_message, file_info['file']['file_name'],file_info['file']['file_size'], start_time))
|
|
|
175 |
|
176 |
+
success_text = LANG.SUCCESS_PRIV_FILE.format(file_info['file']['file_name'], humanbytes(file_size))
|
|
|
177 |
await replied_message.edit_text(
|
178 |
text=success_text,
|
179 |
parse_mode=ParseMode.HTML,
|