Update app.py
Browse files
app.py
CHANGED
|
@@ -50,10 +50,6 @@ scheduler.add_job(reset_daily_counts, CronTrigger(hour=0, minute=0))
|
|
| 50 |
|
| 51 |
# βββββ Schedule Random Group Creation βββββ
|
| 52 |
def schedule_random_group_creation(userbot, acc_doc):
|
| 53 |
-
hour = random.randint(0, 23)
|
| 54 |
-
minute = random.randint(0, 59)
|
| 55 |
-
trigger = CronTrigger(hour=hour, minute=minute, timezone=pytz.timezone("Asia/Kolkata"))
|
| 56 |
-
|
| 57 |
async def job():
|
| 58 |
try:
|
| 59 |
if acc_doc["user_id"] not in userbots:
|
|
@@ -62,18 +58,68 @@ def schedule_random_group_creation(userbot, acc_doc):
|
|
| 62 |
except Exception as e:
|
| 63 |
await bot.send_message(ADMIN_ID, f"β Error for {acc_doc['name']}: {e}")
|
| 64 |
log.info(f"β Group creation error for {acc_doc['name']}: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
# βββββ Group Creator βββββ
|
| 69 |
async def auto_create_groups(userbot, acc_doc):
|
| 70 |
created = 0
|
| 71 |
try:
|
| 72 |
for i in range(random.randint(3, 5)):
|
| 73 |
-
title =
|
| 74 |
-
await userbot(functions.messages.CreateChatRequest(users=[], title=title))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
created += 1
|
| 76 |
await asyncio.sleep(1)
|
|
|
|
|
|
|
| 77 |
accounts.update_one({"_id": acc_doc["_id"]}, {"$inc": {"created": created}})
|
| 78 |
info = await userbot.get_me()
|
| 79 |
await bot.send_message(
|
|
@@ -81,10 +127,12 @@ async def auto_create_groups(userbot, acc_doc):
|
|
| 81 |
f"β
Created {created} groups\nπ€ {info.first_name}\nπ @{info.username or 'N/A'}\nπ Total: {acc_doc['created'] + created}"
|
| 82 |
)
|
| 83 |
log.info(f"π₯ {created} groups created for {acc_doc['name']}")
|
|
|
|
| 84 |
except Exception as e:
|
| 85 |
await bot.send_message(ADMIN_ID, f"β Group creation failed: {e}")
|
| 86 |
log.info(f"β Group creation failed for {acc_doc['name']}: {e}")
|
| 87 |
|
|
|
|
| 88 |
# βββββ Start Userbot βββββ
|
| 89 |
async def start_userbot(session_str, owner_id):
|
| 90 |
try:
|
|
|
|
| 50 |
|
| 51 |
# βββββ Schedule Random Group Creation βββββ
|
| 52 |
def schedule_random_group_creation(userbot, acc_doc):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
async def job():
|
| 54 |
try:
|
| 55 |
if acc_doc["user_id"] not in userbots:
|
|
|
|
| 58 |
except Exception as e:
|
| 59 |
await bot.send_message(ADMIN_ID, f"β Error for {acc_doc['name']}: {e}")
|
| 60 |
log.info(f"β Group creation error for {acc_doc['name']}: {e}")
|
| 61 |
+
finally:
|
| 62 |
+
# Reschedule again for a new random time tomorrow
|
| 63 |
+
schedule_random_group_creation(userbot, acc_doc)
|
| 64 |
+
|
| 65 |
+
# Schedule once with a random time today/tomorrow
|
| 66 |
+
now = datetime.now(pytz.timezone("Asia/Kolkata"))
|
| 67 |
+
random_hour = random.randint(0, 23)
|
| 68 |
+
random_minute = random.randint(0, 59)
|
| 69 |
+
run_time = now.replace(hour=random_hour, minute=random_minute, second=0, microsecond=0)
|
| 70 |
+
if run_time < now:
|
| 71 |
+
run_time += timedelta(days=1)
|
| 72 |
+
|
| 73 |
+
scheduler.add_job(job, trigger='date', run_date=run_time)
|
| 74 |
+
|
| 75 |
+
# βββββ Group Creator βββββ
|
| 76 |
+
import random
|
| 77 |
|
| 78 |
+
adjectives = ["Silent", "Crazy", "Golden", "Hidden", "Brave"]
|
| 79 |
+
nouns = ["Warriors", "Coders", "Friends", "Legends", "Pirates"]
|
| 80 |
+
|
| 81 |
+
def random_group_name():
|
| 82 |
+
return f"{random.choice(adjectives)} {random.choice(nouns)}"
|
| 83 |
|
| 84 |
# βββββ Group Creator βββββ
|
| 85 |
async def auto_create_groups(userbot, acc_doc):
|
| 86 |
created = 0
|
| 87 |
try:
|
| 88 |
for i in range(random.randint(3, 5)):
|
| 89 |
+
title = random_group_name()
|
| 90 |
+
result = await userbot(functions.messages.CreateChatRequest(users=[], title=title))
|
| 91 |
+
group_id = result.chats[0].id
|
| 92 |
+
peer = await userbot.get_input_entity(group_id)
|
| 93 |
+
|
| 94 |
+
# Send 4 "hi" messages
|
| 95 |
+
for _ in range(4):
|
| 96 |
+
await userbot.send_message(peer, "hi")
|
| 97 |
+
await asyncio.sleep(0.5)
|
| 98 |
+
|
| 99 |
+
# Send a sticker
|
| 100 |
+
sticker_ids = [
|
| 101 |
+
"CAACAgIAAxkBAAECyI5lo7uLmhrYRpUkaZ3JvuDkgHJShgACsQEAAladvQoOe5kM_G-xVjME", # Pepe hi
|
| 102 |
+
"CAACAgUAAxkBAAEBI8RlqcdNImkCuc7sWnToYmYGm5CRVQACsAoAAhSg2FbE4J_o-tAnMTME", # Cat love
|
| 103 |
+
"CAACAgUAAxkBAAECRJRlZJcUo0CvCNZjsFlYbGIEjo1jAwACaAoAArVw2FeXBzsoWh9qEDME", # Robot dance
|
| 104 |
+
]
|
| 105 |
+
await userbot.send_file(peer, file=sticker_ids[0], force_document=False)
|
| 106 |
+
|
| 107 |
+
# Send a random quote
|
| 108 |
+
quotes = [
|
| 109 |
+
"βBe yourself; everyone else is already taken.β β Oscar Wilde",
|
| 110 |
+
"βIn the middle of difficulty lies opportunity.β β Albert Einstein",
|
| 111 |
+
"βThe best way to predict the future is to invent it.β β Alan Kay",
|
| 112 |
+
"βLife is what happens when you're busy making other plans.β β John Lennon",
|
| 113 |
+
]
|
| 114 |
+
await userbot.send_message(peer, random.choice(quotes))
|
| 115 |
+
|
| 116 |
+
# Send another sticker
|
| 117 |
+
await userbot.send_file(peer, file=sticker_ids[1], force_document=False)
|
| 118 |
+
|
| 119 |
created += 1
|
| 120 |
await asyncio.sleep(1)
|
| 121 |
+
|
| 122 |
+
# Update created count in MongoDB
|
| 123 |
accounts.update_one({"_id": acc_doc["_id"]}, {"$inc": {"created": created}})
|
| 124 |
info = await userbot.get_me()
|
| 125 |
await bot.send_message(
|
|
|
|
| 127 |
f"β
Created {created} groups\nπ€ {info.first_name}\nπ @{info.username or 'N/A'}\nπ Total: {acc_doc['created'] + created}"
|
| 128 |
)
|
| 129 |
log.info(f"π₯ {created} groups created for {acc_doc['name']}")
|
| 130 |
+
|
| 131 |
except Exception as e:
|
| 132 |
await bot.send_message(ADMIN_ID, f"β Group creation failed: {e}")
|
| 133 |
log.info(f"β Group creation failed for {acc_doc['name']}: {e}")
|
| 134 |
|
| 135 |
+
|
| 136 |
# βββββ Start Userbot βββββ
|
| 137 |
async def start_userbot(session_str, owner_id):
|
| 138 |
try:
|