File size: 3,671 Bytes
0447128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04417e3
1db8c9e
 
 
 
4fb5da0
 
0447128
4fb5da0
 
0447128
4fb5da0
1db8c9e
4fb5da0
1db8c9e
4fb5da0
1db8c9e
4fb5da0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0447128
4fb5da0
 
 
 
 
 
 
 
 
04417e3
0447128
1db8c9e
4fb5da0
1db8c9e
 
 
 
4fb5da0
1db8c9e
 
04417e3
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Test script to verify Logfire tracing is working correctly
"""

import os
import asyncio
from dotenv import load_dotenv
import logfire
# from agent.code_review import logfire_client

load_dotenv()

# async def test_logfire_tracing():
#     """Test basic Logfire functionality"""
    
#     # Test basic span creation
#     with logfire_client.span("test_span", attributes={"test": "basic_functionality"}) as span:
#         span.add_event("test_event", attributes={"message": "Hello from Logfire!"})
#         print("✓ Basic span creation and event logging works")
    
#     # Test error handling
#     try:
#         with logfire_client.span("error_test_span") as span:
#             raise ValueError("Test error for tracing")
#     except ValueError:
#         print("✓ Error tracing works correctly")
    
#     # Test nested spans
#     with logfire_client.span("parent_span") as parent_span:
#         parent_span.add_event("parent_event")
        
#         with logfire_client.span("child_span") as child_span:
#             child_span.add_event("child_event")
#             print("✓ Nested spans work correctly")
    
#     print("✓ All Logfire tests passed!")

# def test_sync_tracing():
#     """Test synchronous tracing"""
#     with logfire_client.span("sync_test") as span:
#         span.add_event("sync_event", attributes={"type": "synchronous"})
#         print("✓ Synchronous tracing works")
    
#     # Test exception handling
#     try:
#         with logfire_client.span("sync_error_test") as span:
#             raise RuntimeError("Sync test error")
#     except RuntimeError:
#         print("✓ Synchronous error tracing works")

# if __name__ == "__main__":
#     print("Testing Logfire tracing functionality...")
#     print(f"Logfire API Key configured: {'Yes' if os.getenv('LOGFIRE_API_KEY') else 'No'}")
#     print()
    
#     # Test sync tracing
#     test_sync_tracing()
    
#     # Test async tracing
#     asyncio.run(test_logfire_tracing())
    
from tool import send_slack_message, list_slack_users, get_slack_usergroups, reply_slack_thread
from dotenv import load_dotenv

load_dotenv()

# report = f"""# [] PR #1: Change something PR
# Hello World

# **🌿 Branch Information:**
# - **Source Branch:**  → **Target Branch:** 

# **👤 Người tạo:** Hải Huỳnh @Hai Huynh

# **📅 Thời gian tạo:** 2024-08-20 14:30:00 +07:00

# **👥 Reviewers:**

# **🔗 Link Pull Request:** [PR #1: Implement user authentication system](https://google.com.vn)
# """


# send_slack_message(
#     message_text = "Hello, *World*",                
#     webhook_url = os.getenv("SLACK_WEBHOOK_URL"),
#     bot_token = os.getenv("SLACK_BOT_TOKEN"),
#     channel = "pull-request",
#     blocks = [
#         {
#             "type": "markdown",
#             "text": report
#         }
#     ]
# ) 

import requests

# Thay token bằng bot token Slack của bạn
SLACK_BOT_TOKEN = os.getenv("SLACK_BOT_TOKEN")
SLACK_WEBHOOK_URL = os.getenv("SLACK_WEBHOOK_URL")
url = "https://slack.com/api/users.list"

users = list_slack_users()
groups = get_slack_usergroups(SLACK_BOT_TOKEN)

# print(users)
# print(groups)

send_slack_message(
    message_text = "",
    channel = "pull-request",
    blocks = [
        {
            "type": "markdown",
            "text": "<@U099W8UMBAQ>"
        }
    ]
) 

resp = send_slack_message("Xin chào team! 🚀", channel="pull-request")
first_message_ts = resp["response"]["ts"]  # lấy ts để trả lời sau

reply_slack_thread(
    thread_ts=first_message_ts,
    message_text="Đây là câu trả lời trong thread 🌱",
    channel="pull-request",
)