Skip to content

Commit 01647a0

Browse files
committed
Username and some heroku stuff
1 parent 9e65d7f commit 01647a0

File tree

5 files changed

+58
-18
lines changed

5 files changed

+58
-18
lines changed

heroku.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build:
2+
docker:
3+
worker: Dockerfile

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ pyrogram
22
TgCrypto
33
python-arq
44
pykeyboard
5-
dotenv
5+
python-dotenv

spr/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from json import loads
12
from os.path import exists
23
from sqlite3 import connect
4+
from urllib.request import urlopen as get
35

46
from aiohttp import ClientSession
57
from pyrogram import Client
@@ -16,6 +18,13 @@
1618
else:
1719
from sample_config import *
1820

21+
# Witchery
22+
BOT_USERNAME = loads(
23+
get(f"https://api.telegram.org/bot{BOT_TOKEN}/getme")
24+
.read()
25+
.decode()
26+
)["result"]["username"]
27+
1928
session = ClientSession()
2029

2130
arq = ARQ(ARQ_API_URL, ARQ_API_KEY, session)

spr/__main__.py

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
77
InlineKeyboardMarkup, Message)
88

9-
from spr import conn, session, spr
9+
from spr import BOT_USERNAME, conn, session, spr
10+
from spr.core import ikb
1011
from spr.modules import MODULES
1112
from spr.utils.misc import once_a_day, paginate_modules
1213

@@ -43,12 +44,36 @@ async def main():
4344
@spr.on_message(filters.command(["help", "start"]), group=2)
4445
async def help_command(_, message: Message):
4546
if message.chat.type != "private":
46-
return await message.reply("Pm Me For Help")
47-
text, keyboard = await help_parser(message.from_user.mention)
48-
await message.reply_text(
49-
text,
50-
reply_markup=keyboard,
51-
quote=False,
47+
kb = ikb({"Help": f"t.me/{BOT_USERNAME}?start=help"})
48+
return await message.reply("Pm Me For Help", reply_markup=kb)
49+
kb = ikb(
50+
{
51+
"Help": "bot_commands",
52+
"Repo": "https://github.com/TheHamkerCat/SpamProtectionRobot",
53+
"Add Me To Your Group": f"https://t.me/{BOT_USERNAME}?startgroup=new",
54+
"Support Chat (for now)": "https://t.me/WBBSupport",
55+
}
56+
)
57+
mention = message.from_user.mention
58+
await message.reply_photo(
59+
"https://hamker.me/logo_3.png",
60+
caption=f"Hi {mention}, I'm SpamProtectionRobot,"
61+
+ " Choose An Option From Below.",
62+
reply_markup=kb,
63+
)
64+
65+
66+
@spr.on_callback_query(filters.regex("bot_commands"))
67+
async def commands_callbacc(_, cq: CallbackQuery):
68+
text, keyboard = await help_parser(cq.from_user.mention)
69+
await asyncio.gather(
70+
cq.answer(),
71+
cq.message.delete(),
72+
spr.send_message(
73+
cq.message.chat.id,
74+
text=text,
75+
reply_markup=keyboard,
76+
),
5277
)
5378

5479

@@ -58,10 +83,9 @@ async def help_parser(name, keyboard=None):
5883
paginate_modules(0, HELPABLE, "help")
5984
)
6085
return (
61-
f"""Hello {name}, I'm SpamProtectionRobot,
62-
And i can protect your group from Spam and NSFW media,
63-
Just add me to your group and i'll keep your group clean from spammers
64-
Choose an option from below.""",
86+
f"Hello {name}, I'm SpamProtectionRobot, I can protect "
87+
+ "your group from Spam and NSFW media using "
88+
+ "machine learning. Choose an option from below.",
6589
keyboard,
6690
)
6791

@@ -73,11 +97,12 @@ async def help_button(client, query: CallbackQuery):
7397
next_match = re.match(r"help_next\((.+?)\)", query.data)
7498
back_match = re.match(r"help_back", query.data)
7599
create_match = re.match(r"help_create", query.data)
76-
top_text = f"""
77-
Hello {query.from_user.first_name}, I'm SpamProtectionRobot,
78-
And i can protect your group from Spam and NSFW media,
79-
Just add me to your group and i'll keep your group clean from spammers
80-
You can choose an option below."""
100+
u = query.from_user.mention
101+
top_text = (
102+
f"Hello {u}, I'm SpamProtectionRobot, I can protect "
103+
+ "your group from Spam and NSFW media using "
104+
+ "machine learning. Choose an option from below."
105+
)
81106
if mod_match:
82107
module = mod_match.group(1)
83108
text = (

spr/modules/info.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ async def inline_info_func(_, query: InlineQuery):
8686
if not entity:
8787
err = "I haven't seen this user/chat."
8888
results = [
89-
InlineQueryResultArticle(err, input_message_content=err)
89+
InlineQueryResultArticle(
90+
err,
91+
input_message_content=InputTextMessageContent(err),
92+
)
9093
]
9194
else:
9295
results = [

0 commit comments

Comments
 (0)