CryptoScoutv1 commited on
Commit
0db14aa
·
verified ·
1 Parent(s): 789e881

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -28,13 +28,16 @@ def get_client(session: Optional[str] = None) -> grc.Client:
28
  client.session_hash = session
29
  return client
30
 
 
31
  def truncate_response(response: str) -> str:
32
  ending = "...\nTruncating response to 2000 characters due to discord api limits."
33
- if len(response) > 2000:
34
- return response[: 2000 - len(ending)] + ending
 
35
  else:
36
  return response
37
 
 
38
  intents = discord.Intents.default()
39
  intents.message_content = True
40
  bot = commands.Bot(command_prefix="/", intents=intents)
 
28
  client.session_hash = session
29
  return client
30
 
31
+ # Adjusting for the ending message length and backticks
32
  def truncate_response(response: str) -> str:
33
  ending = "...\nTruncating response to 2000 characters due to discord api limits."
34
+ max_length = 2000 - len(ending) - 6 # Subtracting 6 for the backticks
35
+ if len(response) > max_length:
36
+ return response[:max_length] + ending
37
  else:
38
  return response
39
 
40
+
41
  intents = discord.Intents.default()
42
  intents.message_content = True
43
  bot = commands.Bot(command_prefix="/", intents=intents)