MCPcopy Create free account
hub / github.com/pollinations/pollinations / handle_thread_message

Function handle_thread_message

apps/polly/src/bot.py:1171–1206  ·  view source on GitHub ↗

Handle a message in an existing thread.

(message: discord.Message, session: ConversationSession)

Source from the content-addressed store, hash-verified

1169
1170
1171async def handle_thread_message(message: discord.Message, session: ConversationSession):
1172 """Handle a message in an existing thread."""
1173 # Type guard: this function is only called for thread messages
1174 if not isinstance(message.channel, discord.Thread):
1175 logger.warning(f"handle_thread_message called with non-thread channel: {type(message.channel)}")
1176 return
1177
1178 channel = message.channel # Now typed as discord.Thread
1179 image_urls, video_urls, file_urls = extract_media_urls(message)
1180
1181 # Add to session
1182 session_manager.add_to_session(
1183 session=session,
1184 role="user",
1185 content=message.content,
1186 author=str(message.author),
1187 author_id=message.author.id,
1188 image_urls=image_urls + video_urls, # Combined for session storage (not files)
1189 )
1190
1191 async with channel.typing():
1192 # Fetch thread history for context
1193 thread_history = await fetch_thread_history(channel)
1194
1195 await process_message(
1196 channel=channel,
1197 user=message.author,
1198 text=message.content,
1199 image_urls=image_urls,
1200 session=session,
1201 thread_history=thread_history,
1202 reply_to=message, # Reply to user's message so they get pinged
1203 source_message=message,
1204 video_urls=video_urls,
1205 file_urls=file_urls,
1206 )
1207
1208
1209async def process_message(

Callers 1

on_messageFunction · 0.85

Calls 4

extract_media_urlsFunction · 0.85
fetch_thread_historyFunction · 0.85
process_messageFunction · 0.85
add_to_sessionMethod · 0.80

Tested by

no test coverage detected