forked from athphane/userbot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'athphane:master' into master
- Loading branch information
Showing
18 changed files
with
340 additions
and
42 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,30 @@ | ||
# Stage 1: Build | ||
FROM python:3.11.5-slim-bullseye AS build | ||
|
||
WORKDIR /root/userbot | ||
|
||
COPY . . | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN --mount=type=cache,target=/var/cache/apt \ | ||
--mount=type=cache,target=/root/.cache/pip \ | ||
apt-get update && \ | ||
apt-get install -y gcc build-essential --no-install-recommends && \ | ||
pip install -r requirements.txt && \ | ||
apt-get autoremove -y gcc build-essential && \ | ||
apt-get clean | ||
|
||
# Stage 2: Run | ||
FROM python:3.11.5-slim-bullseye | ||
|
||
LABEL org.opencontainers.image.source https://github.com/athphane/userbot | ||
LABEL org.opencontainers.image.description "Telegram Userbot Container Image" | ||
LABEL org.opencontainers.image.licenses GPL-3.0 | ||
|
||
WORKDIR /root/userbot | ||
|
||
COPY --from=build /root/userbot . | ||
COPY --from=build /usr/local /usr/local | ||
|
||
CMD python -m userbot |
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,13 @@ | ||
version: '3.5' | ||
services: | ||
######################### | ||
userbot-x86: &userbot-arm | ||
build: | ||
context: ../ | ||
dockerfile: .build/Dockerfile | ||
hostname: userbot | ||
image: ghcr.io/athphane/userbot | ||
platform: linux/amd64/v3 | ||
# userbot-arm: | ||
# <<: *userbot-arm | ||
# platform: linux/arm64 |
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,11 @@ | ||
venv/ | ||
.idea/ | ||
.env | ||
*.session | ||
*.session-journal | ||
__pycache__/ | ||
unknown_errors.txt | ||
file_ids.txt | ||
.cache-* | ||
.git | ||
config/* |
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,23 @@ | ||
name: Docker Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build and push Docker image | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
docker-compose -f .build/docker-compose.yml build | ||
docker login ghcr.io -u $DOCKER_USERNAME -p $DOCKER_PASSWORD | ||
docker-compose -f .build/docker-compose.yml push |
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
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
Empty file.
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 @@ | ||
version: '3.5' | ||
services: | ||
######################### | ||
userbot: | ||
hostname: userbot | ||
volumes: | ||
- ./:/root/userbot | ||
image: ghcr.io/athphane/userbot |
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
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
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
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,109 @@ | ||
import asyncio | ||
|
||
from pyrogram import filters | ||
from pyrogram.enums import ParseMode | ||
from pyrogram.types import Message | ||
|
||
from userbot import UserBot | ||
from userbot.plugins.help import add_command_help | ||
|
||
# Dictionary representing the morse code chart | ||
MORSE_CODE_DICT = {'A': '.-', 'B': '-...', | ||
'C': '-.-.', 'D': '-..', 'E': '.', | ||
'F': '..-.', 'G': '--.', 'H': '....', | ||
'I': '..', 'J': '.---', 'K': '-.-', | ||
'L': '.-..', 'M': '--', 'N': '-.', | ||
'O': '---', 'P': '.--.', 'Q': '--.-', | ||
'R': '.-.', 'S': '...', 'T': '-', | ||
'U': '..-', 'V': '...-', 'W': '.--', | ||
'X': '-..-', 'Y': '-.--', 'Z': '--..', | ||
'1': '.----', '2': '..---', '3': '...--', | ||
'4': '....-', '5': '.....', '6': '-....', | ||
'7': '--...', '8': '---..', '9': '----.', | ||
'0': '-----', ', ': '--..--', '.': '.-.-.-', | ||
'?': '..--..', '/': '-..-.', '-': '-....-', | ||
'(': '-.--.', ')': '-.--.-', ' ': '/'} | ||
|
||
|
||
@UserBot.on_message(filters.command("morse", ".") & filters.me) | ||
async def morse_encrypt(bot: UserBot, message: Message): | ||
cmd = message.command | ||
|
||
def encrypt(input_string): | ||
cipher = '' | ||
for letter in input_string: | ||
if letter != ' ': | ||
cipher += MORSE_CODE_DICT[letter] + ' ' | ||
else: | ||
cipher += ' ' | ||
|
||
return cipher | ||
|
||
main_text = "" | ||
if len(cmd) > 1: | ||
main_text = " ".join(cmd[1:]) | ||
elif message.reply_to_message and len(cmd) == 1: | ||
main_text = message.reply_to_message.text | ||
elif not message.reply_to_message and len(cmd) == 1: | ||
await message.edit("I need something to encrypt") | ||
await asyncio.sleep(2) | ||
await message.delete() | ||
return | ||
|
||
input_str = main_text | ||
if not input_str: | ||
await message.edit("`give me something to encrypt`") | ||
return | ||
|
||
await message.edit(encrypt(input_str.upper()), parse_mode=ParseMode.DISABLED) | ||
|
||
|
||
@UserBot.on_message(filters.command("morsed", ".") & filters.me) | ||
async def morse_decrypt(bot: UserBot, message: Message): | ||
cmd = message.command | ||
|
||
def decrypt(input_string): | ||
input_string += ' ' | ||
decipher = '' | ||
citext = '' | ||
for letter in input_string: | ||
if letter != ' ': | ||
i = 0 | ||
citext += letter | ||
else: | ||
i += 1 | ||
if i == 2: | ||
decipher += ' ' | ||
else: | ||
decipher += list(MORSE_CODE_DICT.keys())[list(MORSE_CODE_DICT.values()).index(citext)] | ||
citext = '' | ||
|
||
return decipher | ||
|
||
main_text = "" | ||
if len(cmd) > 1: | ||
main_text = " ".join(cmd[1:]) | ||
elif message.reply_to_message and len(cmd) == 1: | ||
main_text = message.reply_to_message.text | ||
elif not message.reply_to_message and len(cmd) == 1: | ||
await message.edit("I need something to decrypt") | ||
await asyncio.sleep(2) | ||
await message.delete() | ||
return | ||
|
||
input_str = main_text | ||
if not input_str: | ||
await message.edit("`give me something to decrypt`") | ||
return | ||
|
||
await message.edit(decrypt(input_str).lower(), parse_mode=ParseMode.DISABLED) | ||
|
||
|
||
# Command help section | ||
add_command_help( | ||
"morse", | ||
[ | ||
[".morse", "Encrypt the input text into morse code"], | ||
[".morsed", "Decrypt morse code to plain text"], | ||
], | ||
) |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.