-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathkakao.py
131 lines (110 loc) Β· 4.51 KB
/
kakao.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
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
# -*- coding: utf-8 -*-
"""
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββ βββββββββββββββββββββββ βββ ββββββ βββββββ
βββββββββββ βββββββββββββββββββββββ βββ ββββββββββββββββ
βββββββββββ ββββββ βββ ββββββ βββ ββββββββββββββββ
βββββββββββ ββββββ βββ ββββββ βββ ββββββββββββββββ
ββββββββββββββββββββ βββ ββββββββββββββββββββββ βββββββββββ
ββββββββ βββββββ βββ βββ ββββββββββββββββββββββ ββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Lost Ark wait notifier api
develop by woosik yoon (yoonwoosik12@naver.com)
[suitee.me]
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
"""
from flask import Flask, request, jsonify
from modules.dbtools import *
from modules.crawler import *
from datetime import datetime
app = Flask(__name__)
keyboard_button = {
"type": "buttons",
"buttons": ["λκΈ°μ΄", "μ κ² κ³΅μ§", "μ€λͺ
μ"]
}
message_button = {
'message_button': {
'label': 'κ°λ°μ μ€μ΄λ― λΈλ‘κ·Έ',
'url': 'http://suitee.me'
}
}
def get_wait_text():
db = DbTools(select_only=True)
data = db.get_data()
now = datetime.now()
text = "π€οΈλ‘μ€νΈμν¬ λκΈ°μ΄ μλ¦Όλ΄\n"
text += "βββββββββββ\n"
text += f"{now.hour}μ {now.minute}λΆ {now.second}μ΄ κΈ°μ€\n\n"
# for item in data:
# queue = item[1]
# if item[1] == -1:
# queue = 'μ§μμμ '
#μλ²κ° κΊΌμ Έμμ μ
for item in data:
queue = 0
if item[1] == -1:
queue = 'μ§μμμ '
text += f"{item[0]} : {queue}\n"
text += f"\nλ°μ΄ν° μ 곡 :\nrubystarashe.github.io/lostark\n"
db.close()
return text
def get_notice_text():
crawler = Crawler(use_driver=False)
notices = crawler.start_notice()
text = "π€οΈλ‘μ€νΈμν¬ μ κ² κ³΅μ§\n"
text += "βββββββββββ\n"
for notice in notices:
if type(notice) == str:
text += notice + '\n\n'
else:
text += '\n\n'.join(notice)
text += '\n\n-----------------------\n'
return text
def get_help_text():
text = """π€οΈμλ¦Όλ΄ μ€λͺ
μ
βββββββββββ
1. λκΈ°μ΄
νμ¬ λκΈ°μ΄μ λ³Ό μ μμ΅λλ€.
2. μ κ² κ³΅μ§
곡μ ννμ΄μ§μ μ κ²μμ μΈ κ³΅μ§λ₯Ό λ³Ό μ μμ΅λλ€.
3. μ€λͺ
μ
λ‘μ€νΈμν¬ λκΈ°μ΄ μλ¦Όλ΄ μ€λͺ
μ μ
λλ€.
"""
return text
@app.route('/keyboard')
def keyboard():
data_send = keyboard_button
return jsonify(data_send)
@app.route('/message', methods=['POST'])
def message():
data_receive = request.get_json()
content = data_receive['content']
if content == u"λκΈ°μ΄":
data_send = {
"message": {
"text": get_wait_text()
}
}
elif content == u"μ κ² κ³΅μ§":
data_send = {
"message": {
"text": get_notice_text()
}
}
elif content == u"μ€λͺ
μ":
data_send = {
"message": {
"text": get_help_text()
}
}
else:
data_send = {
"message": {
"text": "λͺ
λ Ήμ΄λ₯Ό λ€μ μ
λ ₯ν΄μ£ΌμΈμ."
}
}
data_send["message"].update(message_button)
data_send["keyboard"] = keyboard_button
return jsonify(data_send)
if __name__ == "__main__":
app.run(host=config.SERVER_CONFIG['host'], port=config.SERVER_CONFIG['port'])