-
Notifications
You must be signed in to change notification settings - Fork 0
/
ml_bot.py
94 lines (93 loc) · 3.98 KB
/
ml_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
87
88
89
90
91
92
93
(
lambda TOKEN, GROUP_ID, URL="https://api.vk.com/method/": (
lambda get: (
lambda globs={
"things": get(URL + "groups.getLongPollServer", {"group_id": GROUP_ID})[
"response"
]
}: (
globs.update(
{
"server": globs["things"]["server"],
"key": globs["things"]["key"],
"ts": globs["things"]["ts"],
}
),
(lambda f: (lambda x: x(x))(lambda y: f(lambda *args: y(y)(*args))))(
lambda w: (
lambda globs: (
globs.update(
{
"things": get(
globs["server"],
{
"act": "a_check",
"key": globs["key"],
"ts": globs["ts"],
"wait": "25",
},
),
}
),
globs.update({"ts": globs["things"]["ts"]}),
[
(
lambda peer_id, message: get(
URL + "messages.send",
{
"peer_id": peer_id,
"message": message,
"random_id": 0,
},
)
)(
update["object"]["message"]["from_id"],
{
"привет": lambda msg: "Привет, {}!".format(
get(
URL + "users.get",
{"user_ids": msg["from_id"]},
)["response"][0]["first_name"]
),
"скажи": lambda msg: msg["text"].partition(" ")[
2:
][0],
"": lambda _: "напиши что-нибудь!",
}.get(
update["object"]["message"]["text"]
.partition(" ")[0]
.lower(),
lambda _: "неизвестная команда!",
)(
update["object"]["message"]
),
)
for update in globs["things"]["updates"]
if update["type"] == "message_new"
],
w(globs),
)
)
)(globs),
)
)()
)(
lambda url, data, request=__import__(
"urllib.request"
).request, parse=__import__("urllib.parse").parse: __import__("json").loads(
request.urlopen(
request.Request(
url,
parse.urlencode(
{**data, "access_token": TOKEN, "v": "5.120"}
).encode(),
)
)
.read()
.decode()
)
)
)(
TOKEN="Your Token",
GROUP_ID="Your Group ID",
)