babalae/better-genshin-impact · error · NotifierException
OneBot message sending failed
Error message
OneBot message sending failed
What it means
Aggregated failure: SendMessage(url, content, isPrivate) returned false for every target that was attempted (private, group, or both). SendMessage returns false on non-success HTTP status OR when the JSON response's status field is not "ok".
Source
Thrown at BetterGenshinImpact/Service/Notifier/OneBotNotifier.cs:83
if (!privateResponse)
{
success = false;
}
}
// 处理群聊消息
if (!string.IsNullOrEmpty(GroupId))
{
var groupResponse = await SendMessage(url, content, false);
if (!groupResponse)
{
success = false;
}
}
if (!success)
{
throw new NotifierException("OneBot message sending failed");
}
}
catch (NotifierException)
{
throw;
}
catch (System.Exception ex)
{
throw new NotifierException($"Error sending OneBot message: {ex.Message}");
}
}
private async Task<bool> SendMessage(string url, BaseNotificationData content, bool isPrivate)
{
// 构建消息内容
var messageContent = new List<object>
{
newView on GitHub (pinned to a7cb36712d)
Solutions
- Inspect the OneBot instance's own log for the retcode/wording (the notifier discards the body, losing detail).
- Verify the access token matches the OneBot access_token setting.
- Confirm the QQ account backing OneBot is online and that the bot can message the target (test manually via the OneBot HTTP API).
- Improve SendMessage to read retcode/wording and bubble them into the exception.
Example fix
// before
using var response = await _httpClient.SendAsync(request);
if (!response.IsSuccessStatusCode)
{
return false;
}
var responseContent = await response.Content.ReadAsStringAsync();
...
return statusElement.GetString() == "ok";
// after — surface the real reason
using var response = await _httpClient.SendAsync(request);
var responseContent = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
throw new NotifierException($"OneBot HTTP {response.StatusCode}: {responseContent}");
using JsonDocument doc = JsonDocument.Parse(responseContent);
var root = doc.RootElement;
var status = root.TryGetProperty("status", out var s) ? s.GetString() : null;
if (status != "ok")
throw new NotifierException($"OneBot status={status}, retcode={root.GetPropertyOrDefault("retcode")}, msg={root.GetPropertyOrDefault("wording")}");
return true; Defensive patterns
Strategy: try-catch
Try / catch
try { await oneBotNotifier.SendAsync(data); }
catch (NotifierException ex) when (ex.Message == "OneBot message sending failed")
{ /* inspect OneBot framework logs for retcode/wording; check token + recipient + bot online state */ } Prevention
- Improve SendMessage to surface retcode/wording in the exception.
- Verify the access token and that the QQ account backing OneBot is online.
- Confirm the bot can message the target (not blocked, group member).
When it happens
Trigger: OneBot API returns non-2xx (wrong token, endpoint not /send_msg, framework down); OR returns 200 with status != "ok" (e.g. {"status":"failed","retcode":1400,"wording":"message not sent"}); recipient QQ/group does not exist or bot is blocked; bot account not logged in.
Common situations: Access token mismatch (401/403); the OneBot instance is running but the QQ account got kicked offline; target user blocked the bot; group_id wrong; send_msg disabled by admin.
Related errors
- MeoW 调用失败,状态码: {response.StatusCode}
- OneBot endpoint is not set
- OneBot requires either a user ID or group ID
- Error sending OneBot message: {ex.Message}
- ServerChan调用失败,状态码: {response.StatusCode}
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/bec031f00a5a9e39.
Report an issue: GitHub.