-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbot.py
86 lines (73 loc) · 2.67 KB
/
bot.py
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
import requests
from telethon import events, Button, TelegramClient
import os
import logging
logging.basicConfig(level=logging.INFO)
try:
API_ID = int(os.environ.get("API_ID", 6))
API_HASH = os.environ.get("API_HASH", None)
TOKEN = os.environ.get("TOKEN", None)
except ValueError:
print("You forgot to fullfill vars")
print("Bot is quitting....")
exit()
except Exception as e:
print(f"Error - {str(e)}")
print("Bot is quitting.....")
exit()
except ApiIdInvalidError:
print("Your API_ID or API_HASH is Invalid.")
print("Bot is quitting.")
exit()
bot = TelegramClient('bin', API_ID, API_HASH)
bin = bot.start(bot_token=TOKEN)
@bin.on(events.NewMessage(pattern="^[!?/]start$"))
async def start(event):
if event.is_group:
await event.reply("**Bin-Checker is Alive**")
return
await event.reply(f"**Heya {event.sender.first_name}**\nIts a Bin-Checker Bot To Check Your Bins Are Valid Or Not.", buttons=[
[Button.url("Mʏ Sᴏᴜʀᴄᴇ Cᴏᴅᴇ", "https://github.com/TgxBotz/Bin-Checker")]
])
@bin.on(events.NewMessage(pattern="^[!?/]help$"))
async def help(event):
text = """
**Welcome to HelpMenu:**
- /start - To Start Me :)
- /help - To Get Help Menu
- /bin - To check is your bin valid or not
"""
await event.reply(text, buttons=[[Button.url("Mʏ Sᴏᴜʀᴄᴇ Cᴏᴅᴇ", "https://github.com/TgxBotz/Bin-Checker")]])
@bin.on(events.NewMessage(pattern="^[!?/]bin"))
async def binc(event):
xx = await event.reply("`Processing.....`")
try:
input = event.text.split(" ", maxsplit=1)[1]
url = requests.get(f"https://bins-su-api.now.sh/api/{input}")
res = url.json()
vendor = res['data']['vendor']
type = res['data']['type']
level = res['data']['level']
bank = res['data']['bank']
country = res['data']['country']
me = (await event.client.get_me()).username
valid = f"""
<b>➤ Valid Bin:</b>
<b>Bin -</b> <code>{input}</code>
<b>Status -</b> <code>Valid Bin</code>
<b>Vendor -</b> <code>{vendor}</code>
<b>Type -</b> <code>{type}</code>
<b>Level -</b> <code>{level}</code>
<b>Bank -</b> <code>{bank}</code>
<b>Country -</b> <code>{country}</code>
<b>Checked By - @{me}</b>
<b>User-ID - {event.sender_id}</b>
"""
await xx.edit(valid, parse_mode="HTML")
except IndexError:
await xx.edit("Plese provide a bin to check\n__`/bin yourbin`__")
except KeyError:
me = (await event.client.get_me()).username
await xx.edit(f"**➤ Invalid Bin:**\n\n**Bin -** `{input}`\n**Status -** `Invalid Bin`\n\n**Checked By -** @{me}\n**User-ID - {event.sender_id}**")
print ("Successfully Started")
bin.run_until_disconnected()