-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
140 lines (126 loc) · 5.18 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# This file is part of the ChannelAutoForwarder distribution (https://github.com/Benchamxd/Telegraph-Uploader).
# Copyright (c) 2021 Rithunand
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# License can be found in < https://github.com/Benchamxd/Telegraph-Uploader/blob/main/License>
import os
from telegraph import upload_file
import pyrogram
from pyrogram import filters, Client
from sample_config import Config
from pyrogram.types import (
InlineQueryResultArticle, InputTextMessageContent,
InlineKeyboardMarkup, InlineKeyboardButton,
CallbackQuery, InlineQuery)
Tgraph = Client(
"Telegra.ph Uploader",
api_id=Config.APP_ID,
api_hash=Config.API_HASH,
bot_token=Config.TG_BOT_TOKEN,
)
@Tgraph.on_message(filters.photo)
async def uploadphoto(client, message):
msg = await message.reply_text("`Tʀʏɪɴɢ Tᴏ Dᴏᴡɴʟᴏᴀᴅ...`")
userid = str(message.chat.id)
img_path = (f"./DOWNLOADS/{userid}.jpg")
img_path = await client.download_media(message=message, file_name=img_path)
await msg.edit_text("`Tʀʏɪɴɢ Tᴏ Uᴘʟᴏᴀᴅ.....`")
try:
tlink = upload_file(img_path)
except:
await msg.edit_text("`⚠️Something went wrong!⚠️`")
else:
await msg.edit_text(f"https://telegra.ph{tlink[0]}")
os.remove(img_path)
@Tgraph.on_message(filters.animation)
async def uploadgif(client, message):
if(message.animation.file_size < 5242880):
msg = await message.reply_text("`Tʀʏɪɴɢ Tᴏ Dᴏᴡɴʟᴏᴀᴅ...`")
userid = str(message.chat.id)
gif_path = (f"./DOWNLOADS/{userid}.mp4")
gif_path = await client.download_media(message=message, file_name=gif_path)
await msg.edit_text("`Tʀʏɪɴɢ Tᴏ Uᴘʟᴏᴀᴅ.....`")
try:
tlink = upload_file(gif_path)
await msg.edit_text(f"https://telegra.ph{tlink[0]}")
os.remove(gif_path)
except:
await msg.edit_text("⚠️Something really Happend Wrong...!⚠️")
else:
await message.reply_text("Size Should Be Less Than 5 mb.")
@Tgraph.on_message(filters.video)
async def uploadvid(client, message):
if(message.video.file_size < 5242880):
msg = await message.reply_text("`Tʀʏɪɴɢ Tᴏ Dᴏᴡɴʟᴏᴀᴅ...`")
userid = str(message.chat.id)
vid_path = (f"./DOWNLOADS/{userid}.mp4")
vid_path = await client.download_media(message=message, file_name=vid_path)
await msg.edit_text("`Tʀʏɪɴɢ Tᴏ Uᴘʟᴏᴀᴅ.....`")
try:
tlink = upload_file(vid_path)
await msg.edit_text(f"https://telegra.ph{tlink[0]}")
os.remove(vid_path)
except:
await msg.edit_text("⚠️Something really Happend Wrong...!⚠️")
else:
await message.reply_text("Size Should Be Less Than 5 mb.")
@Tgraph.on_message(filters.command(["start"]))
async def home(client, message):
buttons = [[
InlineKeyboardButton('Hᴇʟᴘ', callback_data='help'),
InlineKeyboardButton('Cʟᴏsᴇ', callback_data='close')
],
[
InlineKeyboardButton('Oᴜʀ Cʜᴀɴɴᴇʟ', url='https://telegram.me/Romeo_JulietBotSupport'),
InlineKeyboardButton('Dᴇᴠᴇʟᴏᴘᴇʀ', url='https://telegram.me/Warning_MadBoy_is_Here')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await Tgraph.send_message(
chat_id=message.chat.id,
text="""<b>Hey there I'm here.,
I'm Romeo Telegraph Uploader Bot; That Can Upload Photo, Video And Gif to telegraph links.
Simply send me photo, video or gif to upload to telegra.ph ✅
Made With ♥️ By @Romeo_JulietBotSupport</b>""",
reply_markup=reply_markup,
parse_mode="html",
reply_to_message_id=message.message_id
)
@Tgraph.on_message(filters.command(["help"]))
async def help(client, message):
buttons = [[
InlineKeyboardButton('Hᴏᴍᴇ', callback_data='home'),
InlineKeyboardButton('Cʟᴏsᴇ', callback_data='close')
],
[
InlineKeyboardButton('Oᴜʀ Cʜᴀɴɴᴇʟ', url='http://telegram.me/Romeo_JulietBot_Support')
]]
reply_markup = InlineKeyboardMarkup(buttons)
await Tgraph.send_message(
chat_id=message.chat.id,
text="""<b>There Is Nothing To Know More,
Just Send Me A Video/gif/photo Upto 5 mb.
I'll upload it to telegra.ph and give you the direct link✅✅</b>""",
reply_markup=reply_markup,
parse_mode="html",
reply_to_message_id=message.message_id
)
@Tgraph.on_callback_query()
async def button(Tgraph, update):
cb_data = update.data
if "help" in cb_data:
await update.message.delete()
await help(Tgraph, update.message)
elif "close" in cb_data:
await update.message.delete()
elif "home" in cb_data:
await update.message.delete()
await home(Tgraph, update.message)
Tgraph.run()