-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (39 loc) · 1.61 KB
/
main.py
File metadata and controls
51 lines (39 loc) · 1.61 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
"""
Qiita記事通知Bot - メイン実行ファイル
ワークフローのみを記述し、詳細な処理は各サービスに委譲
"""
from src.config import Config
from src.services import QiitaService, SlackService
def main():
"""メイン実行関数"""
try:
# 設定の読み込み
config = Config()
# サービスの初期化
qiita_service = QiitaService(config)
slack_service = SlackService(config)
# メインワークフロー
print("🔍 Qiita記事を取得中...")
articles_by_tag = qiita_service.fetch_qiita_articles()
# 記事が見つかったかどうか
if not qiita_service.has_articles(articles_by_tag):
print("No articles found for any tag.")
return
# 優先順位に基づいて最適な記事を選択
print("📋 最適な記事を選択中...")
selected_articles = qiita_service.select_best_articles(articles_by_tag)
if not selected_articles:
print("No suitable articles found after priority filtering.")
return
# 選択した記事をSlackに通知
print("📤 記事をSlackに通知中...")
success = slack_service.notify_articles(selected_articles)
if success:
print("✅ Slack通知が完了しました。")
else:
print("❌ Slack通知に失敗しました。")
except Exception as e:
print(f"❌ エラーが発生しました: {e}")
raise
if __name__ == "__main__":
main()