Skip to content

Commit 73f700b

Browse files
authored
Add files via upload
1 parent 64cacab commit 73f700b

10 files changed

+522
-0
lines changed

.gitignore

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
### Python template
2+
# Byte-compiled / optimized / DLL files
3+
__pycache__/
4+
*.py[cod]
5+
*$py.class
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
cover/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
.pybuilder/
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
89+
# .python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
99+
__pypackages__/
100+
101+
# Celery stuff
102+
celerybeat-schedule
103+
celerybeat.pid
104+
105+
# SageMath parsed files
106+
*.sage.py
107+
108+
# Environments
109+
.env
110+
.venv
111+
env/
112+
venv/
113+
ENV/
114+
env.bak/
115+
venv.bak/
116+
117+
# Spyder project settings
118+
.spyderproject
119+
.spyproject
120+
121+
# Rope project settings
122+
.ropeproject
123+
124+
# mkdocs documentation
125+
/site
126+
127+
# mypy
128+
.mypy_cache/
129+
.dmypy.json
130+
dmypy.json
131+
132+
# Pyre type checker
133+
.pyre/
134+
135+
# pytype static type analyzer
136+
.pytype/
137+
138+
# Cython debug symbols
139+
cython_debug/
140+

CONTRIBUTING.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributing to FILE-SHARING-BOT
2+
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
3+
4+
- Reporting a bug
5+
- Discussing the current state of the code
6+
- Submitting a fix
7+
- Proposing new features
8+
9+
## We Develop with Github
10+
We use github to host code, to track issues and feature requests, as well as accept pull requests.
11+
12+
1. Fork the repo and create your branch from `MAIN`.
13+
2. If you've added code, please test it.
14+
3. Make sure your code works.
15+
4. Issue that pull request! (develop branch)
16+
17+
## Any contributions you make will be under the GNU General Public License v3.0
18+
In short, when you submit code changes, your submissions are understood to be under the same [GNU General Public License v3.0](https://github.com/CodeXBotz/File-Sharing-Bot/blob/main/LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern.
19+
20+
## Report bugs using Github's [issues](https://github.com/CodeXBotz/File-Sharing-Bot/issues)
21+
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/CodeXBotz/File-Sharing-Bot/issues); it's that easy!
22+

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM python:3.8-slim-buster
2+
WORKDIR /app
3+
4+
COPY requirements.txt requirements.txt
5+
RUN pip3 install -r requirements.txt
6+
7+
COPY . .
8+
9+
CMD python3 main.py

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
worker: python3 main.py

app.json

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"name": "TG File Share/Sharing Bot",
3+
"description": "file sharing bot store posts and it can access by special links",
4+
"keywords": [
5+
"telegram",
6+
"file",
7+
"sharing"
8+
],
9+
"repository": "https://github.com/CodeXBotz/File-Sharing-Bot",
10+
"logo": "https://ibb.co/FgPVtzw",
11+
"env": {
12+
"TG_BOT_TOKEN": {
13+
"description": "Your Bot token, Get it from @Botfather",
14+
"value": ""
15+
},
16+
"OWNER_ID": {
17+
"description": "An integer of consisting of your owner ID",
18+
"value": "1250450587"
19+
},
20+
"APP_ID":{
21+
"description": "your app id, take it from my.telegram.org",
22+
"value": ""
23+
},
24+
"DATABASE_URL": {
25+
"description": "Paste your mongo db url",
26+
"value": "url"
27+
},
28+
"DATABASE_NAME":{
29+
"description": "Enter your DATABASE_NAME ",
30+
"value": "filesharexbot"
31+
},
32+
"API_HASH":{
33+
"description": "your api hash, take it from my.telegram.org",
34+
"value": ""
35+
},
36+
"CHANNEL_ID":{
37+
"description": "make a channel (database channel), then make the bot as admin in channel, and it's id",
38+
"value": "-100"
39+
},
40+
"FORCE_SUB_CHANNEL":{
41+
"description": "id of the channel or group, if you want enable force sub feature else put 0",
42+
"value": "0"
43+
},
44+
"START_MESSAGE": {
45+
"description": "Optional: start message of bot, use HTML parsemode format",
46+
"value": "Hello {first}\n\nI can store private files in Specified Channel and other users can access it from special link."
47+
},
48+
"FORCE_SUB_MESSAGE": {
49+
"description": "Optional: Force Sub message of bot, use HTML parsemode format",
50+
"value": "Hello {first}\n\n<b>You need to join in my Channel/Group to use me\n\nKindly Please join Channel</b>"
51+
},
52+
"ADMINS": {
53+
"description": "A space separated list of user_ids of Admins, they can only create links",
54+
"value": "",
55+
"required": false
56+
},
57+
"PROTECT_CONTENT": {
58+
"description": "Protect contents from getting forwarded",
59+
"value": "False",
60+
"required": false
61+
}
62+
},
63+
"buildpacks": [
64+
{
65+
"url": "heroku/python"
66+
}
67+
],
68+
"formation": {
69+
"worker": {
70+
"quantity": 1,
71+
"size": "eco"
72+
}
73+
}
74+
}
75+

bot.py

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#(©)Codexbotz
2+
3+
from aiohttp import web
4+
from plugins import web_server
5+
6+
import pyromod.listen
7+
from pyrogram import Client
8+
from pyrogram.enums import ParseMode
9+
import sys
10+
from datetime import datetime
11+
12+
from config import API_HASH, APP_ID, LOGGER, TG_BOT_TOKEN, TG_BOT_WORKERS, FORCE_SUB_CHANNEL, CHANNEL_ID, PORT
13+
14+
class Bot(Client):
15+
def __init__(self):
16+
super().__init__(
17+
name="Bot",
18+
api_hash=API_HASH,
19+
api_id=APP_ID,
20+
plugins={
21+
"root": "plugins"
22+
},
23+
workers=TG_BOT_WORKERS,
24+
bot_token=TG_BOT_TOKEN
25+
)
26+
self.LOGGER = LOGGER
27+
28+
async def start(self):
29+
await super().start()
30+
usr_bot_me = await self.get_me()
31+
self.uptime = datetime.now()
32+
33+
if FORCE_SUB_CHANNEL:
34+
try:
35+
link = (await self.get_chat(FORCE_SUB_CHANNEL)).invite_link
36+
if not link:
37+
await self.export_chat_invite_link(FORCE_SUB_CHANNEL)
38+
link = (await self.get_chat(FORCE_SUB_CHANNEL)).invite_link
39+
self.invitelink = link
40+
except Exception as a:
41+
self.LOGGER(__name__).warning(a)
42+
self.LOGGER(__name__).warning("Bot can't Export Invite link from Force Sub Channel!")
43+
self.LOGGER(__name__).warning(f"Please Double check the FORCE_SUB_CHANNEL value and Make sure Bot is Admin in channel with Invite Users via Link Permission, Current Force Sub Channel Value: {FORCE_SUB_CHANNEL}")
44+
self.LOGGER(__name__).info("\nBot Stopped. Join https://t.me/ultroid_official for support")
45+
sys.exit()
46+
try:
47+
db_channel = await self.get_chat(CHANNEL_ID)
48+
self.db_channel = db_channel
49+
test = await self.send_message(chat_id = db_channel.id, text = "Test Message")
50+
await test.delete()
51+
except Exception as e:
52+
self.LOGGER(__name__).warning(e)
53+
self.LOGGER(__name__).warning(f"Make Sure bot is Admin in DB Channel, and Double check the CHANNEL_ID Value, Current Value {CHANNEL_ID}")
54+
self.LOGGER(__name__).info("\nBot Stopped. Join https://t.me/ultroid_official for support")
55+
sys.exit()
56+
57+
self.set_parse_mode(ParseMode.HTML)
58+
self.LOGGER(__name__).info(f"Bot Running..!\n\nCreated by \nhttps://t.me/ultroid_official")
59+
self.LOGGER(__name__).info(f""" \n\n
60+
(っ◔◡◔)っ ♥ ULTROIDOFFICIAL ♥
61+
░╚════╝░░╚════╝░╚═════╝░╚══════╝
62+
""")
63+
self.username = usr_bot_me.username
64+
#web-response
65+
app = web.AppRunner(await web_server())
66+
await app.setup()
67+
bind_address = "0.0.0.0"
68+
await web.TCPSite(app, bind_address, PORT).start()
69+
70+
async def stop(self, *args):
71+
await super().stop()
72+
self.LOGGER(__name__).info("Bot stopped.")

0 commit comments

Comments
 (0)