Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 1 #2

Merged
merged 88 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
8a1d062
Update chatbot.py
ufoptg Jan 24, 2024
c32948e
Update tools.py
ufoptg Jan 24, 2024
2dfbcf8
Update tools.py
ufoptg Jan 24, 2024
325771c
Update helper.py
ufoptg Jan 24, 2024
3e2e096
Update _chatactions.py
ufoptg Jan 24, 2024
1420aa5
Update _chatactions.py
ufoptg Jan 24, 2024
5b4e168
Create custom_markdown.py
ufoptg Jan 24, 2024
3e71afe
Update callbackstuffs.py
ufoptg Jan 24, 2024
3579359
Update misc.py
ufoptg Jan 25, 2024
540c28f
Update pylint.yaml
ufoptg Jan 25, 2024
548e830
Update _wrappers.py
ufoptg Jan 25, 2024
3924105
Update base.py
ufoptg Jan 25, 2024
2297471
Update botchat_db.py
ufoptg Jan 25, 2024
3c261cb
Update ytdl.py
ufoptg Jan 25, 2024
fa02e6c
Create openaihelper.py
ufoptg Jan 25, 2024
78a6dea
Update pylint.yaml
ufoptg Jan 25, 2024
0402fbe
Update pylint.yaml
ufoptg Jan 25, 2024
2e53886
Create google_image.py
ufoptg Jan 25, 2024
11a1966
Update pylint.yaml
ufoptg Jan 25, 2024
2c679f8
Update openaihelper.py
ufoptg Jan 25, 2024
f3fe6a2
Update helper.py
ufoptg Jan 25, 2024
424f48f
Update pmbot.py
ufoptg Jan 25, 2024
de4658a
Update __init__.py
ufoptg Jan 25, 2024
607340e
Update _chatactions.py
ufoptg Jan 25, 2024
52f6afa
pylint: auto fixes
ufoptg Jan 25, 2024
7869e02
Update misc.py
ufoptg Jan 25, 2024
82c1fe7
Update _supporter.py
ufoptg Jan 25, 2024
9b3ef6b
Update extra.py
ufoptg Jan 25, 2024
c5174cc
pylint: auto fixes
ufoptg Jan 25, 2024
304f604
Update _help.py
ufoptg Jan 25, 2024
9a204ad
Update tools.py
ufoptg Jan 26, 2024
7133f62
pylint: auto fixes
ufoptg Jan 26, 2024
c4b876c
Update _chatactions.py
ufoptg Jan 26, 2024
f275a98
pylint: auto fixes
ufoptg Jan 26, 2024
7e6fcfb
Update chatbot.py
ufoptg Jan 26, 2024
86c8a66
pylint: auto fixes
ufoptg Jan 26, 2024
e33217c
Update tools.py
ufoptg Jan 26, 2024
ec71a85
Update _chatactions.py
ufoptg Jan 26, 2024
6662d2c
pylint: auto fixes
ufoptg Jan 26, 2024
3778f41
Update en.yml
ufoptg Jan 26, 2024
1d5ebce
Update tools.py
ufoptg Feb 1, 2024
ba73e73
Update _chatactions.py
ufoptg Feb 1, 2024
f30c8f6
pylint: auto fixes
ufoptg Feb 1, 2024
955306f
Update chatbot.py
ufoptg Feb 1, 2024
f537c1b
pylint: auto fixes
ufoptg Feb 1, 2024
f5afd8e
Update chatbot.py
ufoptg Feb 1, 2024
ba5ad82
pylint: auto fixes
ufoptg Feb 1, 2024
5e4abf4
Update pylint.yaml
ufoptg Feb 1, 2024
4ca28af
Update .env.sample
ufoptg Feb 1, 2024
604b0ed
Update version.py
ufoptg Feb 1, 2024
5e9a56b
Update pylint.yaml
ufoptg Feb 1, 2024
4fe7708
Update misc.py
ufoptg Feb 1, 2024
d41f99d
pylint: auto fixes
ufoptg Feb 1, 2024
2acf09f
Update chatbot.py
ufoptg Feb 1, 2024
c06f7ec
pylint: auto fixes
ufoptg Feb 1, 2024
e39cdfd
Update extra.py
ufoptg Feb 2, 2024
1415330
Update __main__.py
ufoptg Feb 2, 2024
739923b
pylint: auto fixes
ufoptg Feb 2, 2024
2fc4d56
Update __main__.py
ufoptg Feb 2, 2024
53e50ac
pylint: auto fixes
ufoptg Feb 2, 2024
8724b61
Update botchat_db.py
ufoptg Feb 2, 2024
3b48fc9
Update botchat_db.py
ufoptg Feb 2, 2024
00b7dac
Update __main__.py
ufoptg Feb 2, 2024
6ec318f
pylint: auto fixes
ufoptg Feb 2, 2024
a3395ee
Update __main__.py
ufoptg Feb 2, 2024
c4d6b4b
Update helper.py
ufoptg Feb 2, 2024
f67904b
Delete pyUltroid/fns/openaihelper.py
ufoptg Feb 2, 2024
1f0a023
Update tools.py
ufoptg Feb 2, 2024
78d2db2
Update version.py
ufoptg Feb 2, 2024
294f627
Update en.yml
ufoptg Feb 2, 2024
dfe33e8
Update tools.py
ufoptg Feb 2, 2024
dc27363
Update _supporter.py
ufoptg Feb 2, 2024
830c3e2
Create chatgpt.py
ufoptg Feb 2, 2024
b5f19bc
Update chatgpt.py
ufoptg Feb 2, 2024
3803e70
Update requirements.txt
ufoptg Feb 2, 2024
3e2dc9f
Update tools.py
ufoptg Feb 2, 2024
b0da875
Update chatgpt.py
ufoptg Feb 2, 2024
edafc5a
Update chatgpt.py
ufoptg Feb 2, 2024
7c882f5
Delete plugins/chatgpt.py
ufoptg Feb 2, 2024
b897f7f
Update globaltools.py
ufoptg Feb 8, 2024
69c0d85
Merge branch 'TeamUltroid:main' into patch-1
ufoptg Feb 8, 2024
91e861d
Update botchat_db.py
ufoptg Feb 8, 2024
db40b85
Update google_image.py
ufoptg Feb 8, 2024
6682c21
Update custom_markdown.py
ufoptg Feb 8, 2024
9c20158
Update tools.py
ufoptg Feb 8, 2024
9529cd8
Update tools.py
ufoptg Feb 8, 2024
f9e22a4
Update requirements.txt
ufoptg Feb 8, 2024
a2ceb86
Update _supporter.py
ufoptg Feb 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Don't use quotes( " and ' )
# Don't use quotes( " or ' )

API_ID=
API_HASH=
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/pylint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: PyLint
name: PyLint Ultroid
on:
push:
branches: [ dev ]
branches:
- patch-1
- patch-2
paths:
- "**.py"
jobs:
Expand All @@ -12,22 +14,26 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9
cache: "pip"
- name: Install Python lint libraries
run: pip install autopep8 autoflake isort black
- name: Check for showstoppers
run: |
autopep8 --verbose --in-place --recursive --aggressive --aggressive pyUltroid/*.py
autopep8 --verbose --in-place --recursive --aggressive --aggressive assistant/*.py
autopep8 --verbose --in-place --recursive --aggressive --aggressive assistant/manager/*.py
autopep8 --verbose --in-place --recursive --aggressive --aggressive plugins/*.py
- name: Remove unused imports and variables
run: |
autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports pyUltroid/*.py
autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports assistant/*.py
autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports assistant/manager/*.py
autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports plugins/*.py
- name: lint with isort and black
run: |
isort --profile black pyUltroid/*.py
black --fast pyUltroid/*.py
isort assistant/*.py
isort assistant/manager/*.py
black --fast assistant/*.py
Expand All @@ -37,9 +43,8 @@ jobs:
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'pylint: auto fixes'
commit_options: '--no-verify'
commit_options: '--verify'
repository: .
commit_user_name: buddhhu
commit_user_email: [email protected]
commit_author: Amit Sharma <[email protected]>

commit_user_name: ufoptg
commit_user_email: [email protected]
commit_author: ufoptg <[email protected]>
18 changes: 17 additions & 1 deletion assistant/callbackstuffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def text_to_url(event):
"buttons": [
[Button.inline("Remove.bg API", data="abs_rmbg")],
[Button.inline("DEEP API", data="abs_dapi")],
[Button.inline("OpenAI API", data="abs_openapi")],
[Button.inline("🌀ʊʄ⊕ք🌀 API", data="abs_uapi")],
[Button.inline("OCR API", data="abs_oapi")],
[Button.inline("« Back", data="setter")],
],
Expand All @@ -195,6 +197,18 @@ def text_to_url(event):
"text": "Get Your Deep Api from deepai.org and send here.",
"back": "cbs_apiset",
},
"uapi": {
"var": "UFOPAPI",
"name": "UFoP API Key",
"text": "Contact 🌀ʊʄ⊕ք🌀 or Visit @PerthUnity_Bot Support Group\n\n /cancel to cancel",
"back": "cbs_apiset",
},
"openapi": {
"var": "OPENAI_API",
"name": "OPENAI API Key",
"text": "Visit openai.com for an OPENAI Api key!\n\n /cancel to cancel",
"back": "cbs_apiset",
},
"oapi": {
"var": "OCR_API",
"name": "Ocr Api Key",
Expand Down Expand Up @@ -556,7 +570,9 @@ async def emoji(event):
var = "EMOJI_IN_HELP"
name = f"Emoji in `{HNDLR}help` menu"
async with event.client.conversation(pru) as conv:
await conv.send_message("Send emoji u want to set 🙃.\n\nUse /cancel to cancel.")
await conv.send_message(
"Send emoji u want to set 🙃.\n\nUse /cancel to cancel."
)
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
Expand Down
131 changes: 115 additions & 16 deletions assistant/pmbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# --------------------------------------- Imports -------------------------------------------- #

import asyncio
import logging
import os

from telethon.errors.rpcerrorlist import UserNotParticipantError
Expand All @@ -25,8 +27,59 @@
from . import *

botb = KeyManager("BOTBLS", cast=list)
FSUB = udB.get_key("PMBOT_FSUB")
FSUB = Keys.PMBOT_FSUB
PMBOTGROUP = Keys.LOG_CHANNEL
CACHE = {}
SUDOS = Keys.SUDOS
PMUSERS = [OWNER_ID, SUDOS]
logging.basicConfig(
format="%(asctime)s | %(name)s [%(levelname)s] : %(message)s",
level=logging.INFO,
datefmt="%m/%d/%Y, %H:%M:%S",
)
logger = logging.getLogger("DEBUGGING")

# --------------------------------------- Functions -------------------------------------------- #


async def forward_to_multiple(event, *user_ids):
results = []
tasks = []

for user_id in user_ids:
task = asyncio.create_task(event.forward_to(user_id))
tasks.append(task)

for task in tasks:
try:
result = await task
results.append(result)
except Exception as e:
results.append(str(e))

return results


async def check_reply_from_bot(event):
if (event.is_private and event.is_reply) or (
event.chat_id == PMBOTGROUP and event.is_reply and event.reply_to_msg_id
):
if event.chat_id == PMBOTGROUP:
replied_message = await event.client.get_messages(
event.chat_id, ids=event.reply_to_msg_id
)
if replied_message.from_id:
entity = replied_message.from_id.user_id
else:
return False
return entity == 6176247391
else:
# For private messages, no need to check the entity, as it's
# already a reply
return True
return False


# --------------------------------------- Incoming -------------------------------------------- #


Expand All @@ -37,7 +90,6 @@
)
async def on_new_mssg(event):
who = event.sender_id
# doesn't reply to that user anymore
if event.text.startswith("/") or who == OWNER_ID:
return
if FSUB:
Expand Down Expand Up @@ -72,40 +124,87 @@ async def on_new_mssg(event):
if MSG and BTTS:
return await event.reply(MSG, buttons=BTTS)
xx = await event.forward_to(OWNER_ID)
zz = await event.forward_to(PMBOTGROUP)
if event.fwd_from:
await xx.reply(f"From {inline_mention(event.sender)} [`{event.sender_id}`]")
await zz.reply(f"From {inline_mention(event.sender)} [`{event.sender_id}`]")
add_stuff(xx.id, who)
add_stuff(zz.id, who)


# --------------------------------------- Outgoing -------------------------------------------- #


@asst_cmd(
load=AST_PLUGINS,
from_users=[OWNER_ID],
from_users=PMUSERS,
incoming=True,
func=lambda e: e.is_private and e.is_reply,
func=check_reply_from_bot,
)
async def on_out_mssg(event):
x = event.reply_to_msg_id
to_user = get_who(x)
logger.info(f"msg_id: {x}")
if event.chat_id == PMBOTGROUP:
group_to_user = get_who(x)
else:
to_user = get_who(x)

if event.reply_to_msg_id:
replied_message = await event.client.get_messages(
event.chat_id, ids=event.reply_to_msg_id
)
if (
replied_message
and replied_message.fwd_from
and replied_message.fwd_from.from_id
and replied_message.fwd_from.from_id.user_id != 6176247391
):
return
if event.text.startswith("/who"):
try:
k = await asst.get_entity(to_user)
photu = await event.client.download_profile_photo(k.id)
await event.reply(
f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}",
file=photu,
)
if photu:
os.remove(photu)
return
if event.is_private and to_user:
k = await asst.get_entity(to_user)
photu = await event.client.download_profile_photo(k.id)
await event.reply(
f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}",
file=photu,
)
if photu:
os.remove(photu)
return
elif event.chat_id == PMBOTGROUP and group_to_user:
k = await asst.get_entity(group_to_user)
photu = await event.client.download_profile_photo(k.id)
await event.reply(
f"• **Name :** {get_display_name(k)}\n• **ID :** `{k.id}`\n• **Link :** {inline_mention(k)}",
file=photu,
)
if photu:
os.remove(photu)
return
else:
return await event.reply(
"Unable to determine the user. Please reply to a specific message."
)
except BaseException as er:
return await event.reply(f"**ERROR : **{str(er)}")
elif event.text.startswith("/"):
return
if to_user:
await asst.send_message(to_user, event.message)

if event.chat_id == PMBOTGROUP:
if group_to_user:
await asst.send_message(group_to_user, event.message)
else:
return await event.reply(
"Unable to determine the user. Please reply to a specific message."
)
elif event.sender_id in PMUSERS:
if to_user:
await asst.send_message(to_user, event.message)
else:
return await event.reply(
"Unable to determine the user. Please reply to a specific message."
)


# --------------------------------------- Ban/Unban -------------------------------------------- #
Expand Down
16 changes: 10 additions & 6 deletions assistant/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,21 @@ async def ultroid(event):
await event.reply(
f"Hey there {mention}, this is Ultroid Assistant of {me}!\n\n{ok}",
file=udB.get_key("STARTMEDIA"),
buttons=[Button.inline("Info.", data="ownerinfo")]
if Owner_info_msg
else None,
buttons=(
[Button.inline("Info.", data="ownerinfo")]
if Owner_info_msg
else None
),
)
else:
await event.reply(
udB.get_key("STARTMSG").format(me=me, mention=mention),
file=udB.get_key("STARTMEDIA"),
buttons=[Button.inline("Info.", data="ownerinfo")]
if Owner_info_msg
else None,
buttons=(
[Button.inline("Info.", data="ownerinfo")]
if Owner_info_msg
else None
),
)
else:
name = get_display_name(event.sender)
Expand Down
Loading
Loading