-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
91 lines (77 loc) · 2.4 KB
/
Copy pathmain.py
File metadata and controls
91 lines (77 loc) · 2.4 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
#!/usr/bin/env python3
## Random User Bot
## Get random user from telegram bot
## GITHUB: https://github.com/Kourva
# Imports
import requests
import telebot
import json
# Config
token = "Your Token"
bot = telebot.TeleBot(token)
# Start Message
print("Bot is online...\n")
# Random User Generator
def generator():
response = requests.get("https://randomuser.me/api/")
data = response.json()
return data
# Start command
@bot.message_handler(commands=["start"])
def start_command(message):
bot.send_chat_action(message.chat.id, "typing")
bot.reply_to(
message,
"привет {user}".format(user=message.from_user.first_name)
)
# Generate command
@bot.message_handler(commands=["generate"])
def generate_command(message):
data = generator()
# Personal info
title_name = data["results"][0]["name"]["title"]
first_name = data["results"][0]["name"]["first"]
last_name = data["results"][0]["name"]["last"]
picture = data["results"][0]["picture"]["large"]
age = data["results"][0]["dob"]["age"]
dob = data["results"][0]["dob"]["date"]
id_name = data["results"][0]["id"]["name"]
id_value = data["results"][0]["id"]["value"]
# Location info
location_street_name = data["results"][0]["location"]["street"]["name"]
location_street_number = data["results"][0]["location"]["street"]["number"]
location_city = data["results"][0]["location"]["city"]
location_state = data["results"][0]["location"]["state"]
location_country = data["results"][0]["location"]["country"]
location_post_code = data["results"][0]["location"]["postcode"]
# Social info
email = data["results"][0]["email"]
phone = data["results"][0]["phone"]
cell = data["results"][0]["cell"]
username = data["results"][0]["login"]["username"]
password = data["results"][0]["login"]["password"]
result = \
f"""
{title_name} {first_name} {last_name} - {age} YO
- Day of Birth: {dob.split("T")[0]}
- ID: {id_name} - {id_value}
Location:
- Country: {location_country}
- State: {location_state}
- City: {location_city}
- Street: {location_street_number} - {location_street_name}
Social Media:
- Email: {email}
- Phone: {phone}
- Cell: {cell}
- Username: {username}
- Password: {password}
"""
bot.send_chat_action(message.chat.id, "upload_photo")
bot.send_photo(
message.chat.id,
picture,
result
)
# Run
bot.infinity_polling()