-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperson.lua
More file actions
48 lines (37 loc) · 1.07 KB
/
person.lua
File metadata and controls
48 lines (37 loc) · 1.07 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
--[[
Person (Beta)
Генерирует случайного юзера
{person male}$
{person female}$
{person}$
by https://t.me/aye_ya
--]]
require "com.wavecat.inline.libs.http"
local baseurl = "https://randomuser.me/api/?format=json"
local function person(_, query)
local request = http.Request.Builder.new():url(
baseurl .. "&gender=" .. (query == "female" and "female&nat" or "male")
):get():build()
query:answer "Loading"
http.call(
request,
function(_, _, string)
local json = json.load(string).results[1]
result =
string.format(
"Name: %s %s\nAge: %d\nLocation: %s, %s\nPhoto: %s",
json.name.first,
json.name.last,
json.dob.age,
json.location.city,
json.location.country,
json.picture.large
)
query:answer(result)
end
)
end
return function(module)
module:setCategory "Person"
module:registerCommand("person", person, "Generates people")
end