Skip to content

Commit

Permalink
Merge branch 'owner' into owner
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 authored Jul 16, 2023
2 parents fddfe84 + e7b261c commit a3e9e99
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions utils/gpt_model/claude.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time, logging
import asyncio
import asyncio, threading
import concurrent.futures

from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
Expand All @@ -15,6 +16,7 @@ class Claude:
client = None
last_message_timestamp = None
dm_channel_id = None


def __init__(self, data):
self.common = Common()
Expand All @@ -33,6 +35,8 @@ def __init__(self, data):
if not self.dm_channel_id:
logging.error("Could not find DM channel with the bot.")
return None

loop = asyncio.new_event_loop()

### claude
def send_message(self, channel, text):
Expand All @@ -48,7 +52,7 @@ def fetch_messages(self, channel, last_message_timestamp):
return [msg['text'] for msg in response['messages'] if msg['user'] == self.bot_user_id]


async def get_new_messages(self, channel, last_message_timestamp):
def get_new_messages(self, channel, last_message_timestamp):
timeout = 60 # 超时时间设置为60秒
start_time = time.time()

Expand All @@ -58,9 +62,7 @@ async def get_new_messages(self, channel, last_message_timestamp):
return messages[-1]
if time.time() - start_time > timeout:
return None

await asyncio.sleep(5)



def find_direct_message_channel(self, user_id):
try:
Expand Down

0 comments on commit a3e9e99

Please sign in to comment.