forked from DevsExpo/AccountGenBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
164 lines (142 loc) · 6.71 KB
/
bot.py
File metadata and controls
164 lines (142 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
9# Copyright (C) Midhun KM 2020-2021
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import requests
from telethon.tl.types import InputWebDocument
from telethon import TelegramClient, events
from starkfunc import check_if_subbed
from telethon import custom, events, Button
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import MessageEntityMentionName
from Configs import Config
from loggers import logging
from apscheduler.schedulers.asyncio import AsyncIOScheduler
import os
import random
import re
from math import ceil
import telethon
import users_sql as warner
from telethon import Button, custom, events, functions
bot = TelegramClient("bot", api_id=Config.API_ID, api_hash=Config.API_HASH)
warnerstarkbot = bot.start(bot_token=Config.BOT_TOKEN)
@warnerstarkbot.on(events.NewMessage(pattern="^/start$"))
async def hmm(event):
if Config.JTU_ENABLE:
starky = await check_if_subbed(Config.CHANNEL_USERNAME,CHANNEL_USERNAME2, event, warnerstarkbot)
if starky is False:
await event.reply("**I am Sorry To Say That, To Access Me You Have To Be The Member Of Our Channel To Use This Bot..!**", buttons=[[custom.Button.url("Join Channel", Config.CHANNEL_URL)],buttons=[[custom.Button.url("Join Channel", Config.CHANNEL_URL2)]])
return
st = await event.client(GetFullUserRequest(event.sender_id))
user_text = f"""**Hello {st.user.first_name},
Welcome To {Config.ACCOUNT_GEN_NAME} Account Generator Bot
To Know About commands type:
/cmds
Bot Made With Love By @MadPremium**
"""
await event.reply(user_text)
@warnerstarkbot.on(events.NewMessage(pattern="^/(help|cmds|commands|cmd|command)$"))
async def cmds(event):
if Config.JTU_ENABLE:
starky = await check_if_subbed(Config.CHANNEL_USERNAME, event, warnerstarkbot)
if starky is False:
await event.reply("**I am Sorry To Say That, To Access Me You Have To Be The Member Of Our Channel To Use This Bot..!**", buttons=[[custom.Button.url("Join Channel", Config.CHANNEL_URL)],
buttons=[[custom.Button.url("Join Channel", Config.CHANNEL_URL2)]
])
return
st = await event.client(GetFullUserRequest(event.sender_id))
help_text = f"""**Hello {st.user.first_name},
My Commands Are As Follows:
/start - To Restart Bot..!
/cmds - To Get Help Menu
/generate - To Generate Netflix Accounts
/about - To Get Your Current Info
Share And Support Us...❤️**
"""
await event.reply(help_text)
@warnerstarkbot.on(events.NewMessage(pattern="^/(generate|gen|account)$"))
async def hmm(event):
if Config.JTU_ENABLE:
starky = await check_if_subbed(Config.CHANNEL_USERNAME, event, warnerstarkbot)
if starky is False:
await event.reply("**I am Sorry To Say That, To Access Me You Have To Be The Member Of Our Channel To Use This Bot..!**", buttons=[[custom.Button.url("Join Channel", Config.CHANNEL_URL)]])
return
hmmw = await event.reply("**Generating Account...Stay Tuned.**")
if warner.is_user_in_db(int(event.sender_id)):
hmm = warner.get_user_info(int(event.sender_id))
if warner.is_user_in_db(int(event.sender_id)) >= Config.GEN_LIMIT_PERDAY:
await hmmw.edit(f"**Your Daily Limit is exhausted, Kindly Contact the admins to increase ur limit\n\nBy The Way Daily Limit is {Config.GEN_LIMIT_PERDAY} accounts per day**", buttons=[[custom.Button.url("Join Channel", Config.CHANNEL_URL)]])
return
warner.update_user_usage(int(event.sender_id), int(1))
else:
warner.add_new_user(int(event.sender_id), int(1))
print("New User : " + str(event.sender_id))
with open('hits.txt') as f:
stark_dict = f.read().splitlines()
sed = random.choice(stark_dict)
user_s = await warnerstarkbot.get_me()
username = user_s.username
email, password = sed.split(":")
await hmmw.edit(
f"<b><u>{Config.ACCOUNT_GEN_NAME} Account Generated.</u></b> \n<b>Email :</b> <code>{email}</code> \n<b>Password :</b><code>{password}</code> \n<b>You Can Check Your Limit or Info By /about<b> \n<b>Generated By @{username}</b>",
parse_mode="HTML")
@warnerstarkbot.on(events.NewMessage(pattern="^/reset$"))
async def reset(event):
if event.sender_id != Config.OWNER_ID:
print("A Non Owner Used This Cmd")
return
ok = warner.get_all_users_id()
for s in ok:
try:
warner.rm_user(int(s))
await warnerstarkbot.send_message(int(s), "**Limit Has Been Reset , Generate Your Accounts Now !**")
except:
pass
await event.reply("Reset Sucessfull Done!")
@warnerstarkbot.on(events.NewMessage(pattern="^/broadcast"))
async def reset(event):
if event.sender_id != Config.OWNER_ID:
print("A Non Owner Used This Cmd")
return
error = 0
ds = event.text.split(" ", maxsplit=1)[1]
ok = warner.get_all_users_id()
for s in ok:
try:
await warnerstarkbot.send_message(int(s), ds)
except:
error += 1
pass
await event.reply(f"Broadcast Done With {error} And Sucess in {len(ok) - error}!")
async def clear_data():
ok = warner.get_all_users_id()
for s in ok:
try:
warner.rm_user(int(s))
await warnerstarkbot.send_message(int(s), "**Limit Has Been Reset , Generate Your Accounts Now !**")
except:
pass
@warnerstarkbot.on(events.NewMessage(pattern="^/about$"))
async def a(event):
if not warner.is_user_in_db(int(event.sender_id)):
await event.reply(f"User-ID : {event.sender_id} \nLimit Used : 0 \nLimit Left : {Config.GEN_LIMIT_PERDAY}")
return
info_s = warner.get_user_info(int(event.sender_id))
await event.reply(f"**📡Your Account Information\n\nUser-ID : {event.sender_id} \nLimit Used : {warner.is_user_in_db(int(event.sender_id))} \nLimit Left : {Config.GEN_LIMIT_PERDAY-warner.is_user_in_db(int(event.sender_id))}**")
scheduler = AsyncIOScheduler(timezone="Asia/Kolkata")
scheduler.add_job(clear_data, trigger="cron", hour=6)
scheduler.start()
print("Bot Started Successfully")
def startbot():
warnerstarkbot.run_until_disconnected()
if __name__ == "__main__":
startbot()