Add reply functionality to manual message override with mention control
- Added optional reply message ID field to web UI
- Added radio buttons to control mention/ping behavior in replies
- Updated frontend JavaScript to send reply parameters
- Modified /manual/send and /dm/{user_id}/manual endpoints to support replies
- Fixed async context by moving message fetching inside bot event loop task
- Supports both channel and DM reply functionality
This commit is contained in:
@@ -885,6 +885,24 @@
|
||||
<label for="manualUserId">User ID:</label>
|
||||
<input type="text" id="manualUserId" placeholder="Enter user ID for DM..." style="width: 100%;" />
|
||||
</div>
|
||||
|
||||
<!-- Reply Configuration -->
|
||||
<div style="margin-top: 0.5rem;">
|
||||
<label for="manualReplyMessageId">Reply to Message ID (optional):</label>
|
||||
<input type="text" id="manualReplyMessageId" placeholder="Enter message ID to reply to..." style="width: 100%;" />
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 0.5rem;">
|
||||
<label style="margin-right: 1rem;">Mention user in reply:</label>
|
||||
<label>
|
||||
<input type="radio" name="manualReplyMention" value="true" checked />
|
||||
Yes (ping user)
|
||||
</label>
|
||||
<label style="margin-left: 1rem;">
|
||||
<input type="radio" name="manualReplyMention" value="false" />
|
||||
No (silent reply)
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button onclick="sendManualMessage()" style="margin-top: 0.5rem;">Send as Miku</button>
|
||||
<p id="manualStatus" style="color: green; margin-top: 0.5rem;"></p>
|
||||
@@ -2347,6 +2365,8 @@ async function sendManualMessage() {
|
||||
const message = document.getElementById('manualMessage').value.trim();
|
||||
const files = document.getElementById('manualAttachment').files;
|
||||
const targetType = document.getElementById('manual-target-type').value;
|
||||
const replyMessageId = document.getElementById('manualReplyMessageId').value.trim();
|
||||
const replyMention = document.querySelector('input[name="manualReplyMention"]:checked').value === 'true';
|
||||
|
||||
if (!message) {
|
||||
showNotification('Please enter a message', 'error');
|
||||
@@ -2375,6 +2395,12 @@ async function sendManualMessage() {
|
||||
const formData = new FormData();
|
||||
formData.append('message', message);
|
||||
|
||||
// Add reply parameters if message ID is provided
|
||||
if (replyMessageId) {
|
||||
formData.append('reply_to_message_id', replyMessageId);
|
||||
formData.append('mention_author', replyMention);
|
||||
}
|
||||
|
||||
if (targetType === 'dm') {
|
||||
// For DM, the user_id is in the URL path
|
||||
if (files.length > 0) {
|
||||
@@ -2403,6 +2429,7 @@ async function sendManualMessage() {
|
||||
showNotification('Message sent successfully');
|
||||
document.getElementById('manualMessage').value = '';
|
||||
document.getElementById('manualAttachment').value = ''; // Clear file input
|
||||
document.getElementById('manualReplyMessageId').value = ''; // Clear reply message ID
|
||||
if (targetType === 'dm') {
|
||||
document.getElementById('manualUserId').value = '';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user