-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 31799ba
Showing
18 changed files
with
1,906 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: pyLint | ||
on: push | ||
jobs: | ||
PEP8: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.10.x | ||
- name: Install Python lint libraries | ||
run: | | ||
pip install autopep8 autoflake isort black | ||
- name: Check for showstoppers | ||
run: autopep8 --verbose --in-place --recursive --aggressive --aggressive . | ||
- name: Remove unused imports and variables | ||
run: autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports . | ||
- name: lint with isort and black | ||
run: | | ||
isort . | ||
black --fast . | ||
# commit changes | ||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: 'pyLint: auto-fixes' | ||
commit_options: '--no-verify' | ||
repository: . | ||
commit_user_name: kaif-00z | ||
commit_user_email: 88398455+kaif-00z@users.noreply.github.com | ||
commit_author: kaif-00z <88398455+kaif-00z@users.noreply.github.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Mandatory Environment Variable | ||
|
||
BOT_TOKEN= | ||
MAIN_CHANNEL=-1001111 | ||
LOG_CHANNEL=-1001111 | ||
CLOUD_CHANNEL=-1001111 | ||
REDIS_URI= | ||
REDIS_PASS= | ||
OWNER=1872074304 | ||
|
||
# Optional Environment Variable | ||
|
||
BACKUP_CHANNEL=-1001111 | ||
THUMBNAIL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM python:3.10.4-slim-buster | ||
RUN mkdir /bot && chmod 777 /bot | ||
WORKDIR /bot | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt -qq update && apt -qq install -y git wget pv jq python3-dev ffmpeg mediainfo gcc | ||
COPY . . | ||
RUN pip3 install -U -r requirements.txt | ||
CMD ["bash","run.sh"] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Todo | ||
|
||
- Need to improve rename code and english rename | ||
- Need to Optimize Core | ||
- Need a better README.md | ||
|
||
## Contributing | ||
|
||
- Any Sort of Contributions are Welcomed! | ||
- Try To Resove Any Task From ToDo List! | ||
|
||
## Donate | ||
|
||
- [Contact me on Telegram](t.me/kaif_00z) if you would like to donate me for my work! | ||
|
||
## Credits | ||
|
||
- [Danish Bhaiya For Ffmpeg Stuff.](https://github.com/1danish-00/) | ||
- Amirul and Yash For qBittorrent stuffs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
import asyncio | ||
import os | ||
import random | ||
import sys | ||
from traceback import format_exc | ||
|
||
try: | ||
from telethon import TelegramClient | ||
from telethon.sessions import StringSession | ||
from telethon.tl.functions.channels import CreateChannelRequest | ||
from telethon.tl.functions.contacts import UnblockRequest | ||
except ModuleNotFoundError: | ||
print("Downloading Telethon...") | ||
os.system(f"{sys.executable} -m pip install telethon") | ||
from telethon import TelegramClient | ||
from telethon.sessions import StringSession | ||
from telethon.tl.functions.channels import CreateChannelRequest | ||
from telethon.tl.functions.contacts import UnblockRequest | ||
|
||
DATA = {} | ||
ENV = """ | ||
BOT_TOKEN={} | ||
MAIN_CHANNEL={} | ||
LOG_CHANNEL={} | ||
CLOUD_CHANNEL={} | ||
REDIS_URI={} | ||
REDIS_PASS={} | ||
OWNER={} | ||
""" | ||
|
||
|
||
async def generate_session_string(): | ||
api_id = int(input("Enter your API_ID: ")) | ||
api_hash = input("Enter your API_HASH: ") | ||
if api_id and api_hash: | ||
async with TelegramClient(StringSession(), api_id, api_hash) as client: | ||
return (str(client.session.save()), api_id, api_hash) | ||
print("API_ID and HASH Not Found!") | ||
sys.exit(1) | ||
|
||
|
||
def get_redis(): | ||
redis_uri = input("Enter your Redis URI: ") | ||
redis_pass = input("Enter your Redis Password: ") | ||
if redis_uri and redis_pass: | ||
DATA["redis_uri"] = redis_uri | ||
DATA["redis_pass"] = redis_pass | ||
else: | ||
DATA["redis_uri"] = "" | ||
DATA["redis_pass"] = "" | ||
return False | ||
|
||
|
||
async def create_channel(client, title): | ||
try: | ||
r = await client( | ||
CreateChannelRequest( | ||
title=title, | ||
about="Made By https://github.com/kaif-00z/AutoAnimeBot", | ||
megagroup=False, | ||
) | ||
) | ||
|
||
created_chat_id = r.chats[0].id | ||
return f"-100{created_chat_id}" | ||
except BaseException: | ||
print("Unable to Create Channel...") | ||
sys.exit(1) | ||
|
||
|
||
def generate_env(): | ||
txt = ENV.format( | ||
DATA["bot_token"], | ||
DATA["Ongoing Anime 2023"], | ||
DATA["Ongoing Anime Logs"], | ||
DATA["Ongoing Anime Samples And SS"], | ||
DATA.get("redis_uri") or "", | ||
DATA.get("redis_pass") or "", | ||
DATA["owner_id"], | ||
) | ||
with open(".env", "w") as f: | ||
f.write(txt.strip()) | ||
print("Succesfully Generated .env File Don't Forget To Save It! For Future Uses.") | ||
|
||
|
||
async def auto_maker(): | ||
string_session, api_id, api_hash = await generate_session_string() | ||
print(string_session) | ||
async with TelegramClient( | ||
StringSession(string_session), api_id, api_hash | ||
) as client: | ||
print("Creating Bot Account...") | ||
who = await client.get_me() | ||
DATA["owner_id"] = who.id | ||
name = who.first_name + "'s Auto Anime Bot" | ||
if who.username: | ||
username = who.username + "_anime_bot" | ||
else: | ||
username = "ongoing_anime_" + (str(who.id))[5:] + "_bot" | ||
bf = "@BotFather" | ||
await client(UnblockRequest(bf)) | ||
await client.send_message(bf, "/cancel") | ||
await asyncio.sleep(1) | ||
await client.send_message(bf, "/newbot") | ||
await asyncio.sleep(1) | ||
isdone = (await client.get_messages(bf, limit=1))[0].text | ||
if isdone.startswith("That I cannot do.") or "20 bots" in isdone: | ||
print( | ||
"You Already Made 20 Bots In Your Current Account. You Have To Deleted One Bot To Run This Script." | ||
) | ||
sys.exit(1) | ||
await client.send_message(bf, name) | ||
await asyncio.sleep(1) | ||
isdone = (await client.get_messages(bf, limit=1))[0].text | ||
if not isdone.startswith("Good."): | ||
print( | ||
"Please make a Bot from @BotFather and add it's token in BOT_TOKEN, as an env var and restart me." | ||
) | ||
sys.exit(1) | ||
await client.send_message(bf, username) | ||
await asyncio.sleep(1) | ||
isdone = (await client.get_messages(bf, limit=1))[0].text | ||
await client.send_read_acknowledge("botfather") | ||
if isdone.startswith("Sorry,"): | ||
ran = random.randint(1, 100) | ||
username = "ongoing_anime_" + (str(who.id))[6:] + str(ran) + "_bot" | ||
await client.send_message(bf, username) | ||
await asyncio.sleep(1) | ||
isdone = (await client.get_messages(bf, limit=1))[0].text | ||
if isdone.startswith("Done!"): | ||
bot_token = isdone.split("`")[1] | ||
DATA["bot_token"] = bot_token | ||
print("Succesfully Created Bot Account...") | ||
print("Creating Channels...") | ||
for ch_name in [ | ||
"Ongoing Anime Logs", | ||
"Ongoing Anime 2023", | ||
"Ongoing Anime Samples And SS", | ||
]: | ||
try: | ||
chat_id = await create_channel(client, ch_name) | ||
await asyncio.sleep(3) | ||
await client.edit_admin( | ||
chat_id, | ||
username, | ||
post_messages=True, | ||
edit_messages=True, | ||
delete_messages=True, | ||
ban_users=True, | ||
pin_messages=True, | ||
add_admins=True, | ||
) | ||
DATA[ch_name] = chat_id | ||
except BaseException: | ||
print("Error While Creating Channel And Promoting Bot..") | ||
print(format_exc()) | ||
sys.exit(1) | ||
print("Succesfully Created Channel...") | ||
db = get_redis() | ||
if not db: | ||
print( | ||
"Generating .env Without Redis URI and Password. Now You Have To Add it Manually!" | ||
) | ||
generate_env() | ||
|
||
|
||
asyncio.run(auto_maker()) |
Oops, something went wrong.