Skip to content

Commit 39ce569

Browse files
authored
Merge pull request #623 from dev-hato/develop
リリース
2 parents d855470 + a04b504 commit 39ce569

4 files changed

Lines changed: 35 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
* `Removed` 削除された機能について。
88
* `Fixed` バグ修正について。
99

10+
## v2.1.1 - 2021-06-17
11+
12+
### Fixed
13+
14+
* リクエスト再送による重複投稿をなくしました。(#620)
15+
1016
## v2.1.0 - 2021-06-13
1117

1218
### Changed

plugins/hato.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from library.clientclass import BaseClient
2424
from library.jma_amesh import jma_amesh
2525
logger = getLogger(__name__)
26-
VERSION = "2.1.0"
26+
VERSION = "2.1.1"
2727

2828

2929
def split_command(command: str, maxsplit: int = 0) -> List[str]:

run.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import plugins.hato as hato
1515
import plugins.analyze as analyze
1616
from library.clientclass import SlackClient, ApiClient
17+
from library.database import Database
1718

1819
app = Flask(__name__)
1920

@@ -53,6 +54,32 @@ def on_app_mention(event_data):
5354
channel = event_data["event"]["channel"]
5455
blocks = event_data['event']['blocks']
5556
authed_users = event_data['authed_users']
57+
client_msg_id = event_data['event']['client_msg_id']
58+
59+
print(f'event_data: {event_data}')
60+
print(f'channel: {channel}')
61+
print(f'blocks: {blocks}')
62+
print(f'authed_users: {authed_users}')
63+
print(f'client_msg_id: {client_msg_id}')
64+
65+
with Database() as _db, _db.conn.cursor() as cursor:
66+
cursor.execute(
67+
'SELECT client_msg_id FROM slack_client_msg_id WHERE client_msg_id = %s LIMIT 1',
68+
(client_msg_id,))
69+
70+
if cursor.fetchone():
71+
print('skip')
72+
return
73+
74+
cursor.execute(
75+
"DELETE FROM slack_client_msg_id "
76+
"WHERE created_at < CURRENT_TIMESTAMP - interval '10 minutes'",
77+
(client_msg_id,))
78+
cursor.execute(
79+
'INSERT INTO slack_client_msg_id(client_msg_id, created_at) '
80+
'VALUES(%s, CURRENT_TIMESTAMP)',
81+
(client_msg_id,))
82+
_db.conn.commit()
5683

5784
with ThreadPoolExecutor(max_workers=3) as tpe:
5885
for block in blocks:
@@ -68,11 +95,6 @@ def on_app_mention(event_data):
6895
SlackClient(channel,
6996
block_element_elements[0]['user_id']))
7097

71-
print(f'event_data: {event_data}')
72-
print(f'channel: {channel}')
73-
print(f'blocks: {blocks}')
74-
print(f'authed_users: {authed_users}')
75-
7698

7799
@app.route("/", methods=["GET", "POST"])
78100
def http_app():

setup/pgsql-init/02_init.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
CREATE TABLE IF NOT EXISTS vocabulary(no serial UNIQUE, word text);
2+
CREATE TABLE IF NOT EXISTS slack_client_msg_id(client_msg_id text unique, created_at timestamp);

0 commit comments

Comments
 (0)