Skip to content

Commit

Permalink
v5.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
trueai-org committed Oct 18, 2024
1 parent 1be3a12 commit e22eb6d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ The most powerful, complete, full-featured, completely free and open source Midj
- [x] 支持视频换脸,请遵守相关法律法规,不得用于违法用途
- [x] 支持自动切换到慢速模式、支持自动切快速模式、支持自动设置慢速
- [x] 私信 ID 免配置,服务启动时自动获取私信 ID
- [x] 自动过 Tos not accepted 验证

## 在线预览

Expand Down
5 changes: 5 additions & 0 deletions src/Midjourney.API/DiscordAccountInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ public async Task StartCheckAccount(DiscordAccount account, bool isValidateLock
if (account.FastExhausted == true && account.EnableAutoSetRelax == true)
{
account.AllowModes = new List<GenerationSpeedMode>() { GenerationSpeedMode.RELAX };

if (account.CoreSize > 3)
{
account.CoreSize = 3;
}
}

try
Expand Down
2 changes: 1 addition & 1 deletion src/Midjourney.API/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
</head>
<body>
<div id="root"></div>
<script src="/umi.70f82ef5.js"></script>
<script src="/umi.8d92f439.js"></script>
</body>
</html>

Large diffs are not rendered by default.

41 changes: 40 additions & 1 deletion src/Midjourney.Infrastructure/BotMessageListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,14 @@ public void OnMessage(JsonElement raw)
if (Account.FastExhausted == true && Account.EnableAutoSetRelax == true)
{
Account.AllowModes = new List<GenerationSpeedMode>() { GenerationSpeedMode.RELAX };

if (Account.CoreSize > 3)
{
Account.CoreSize = 3;
}
}

DbHelper.AccountStore.Update("AllowModes,FastExhausted", Account);
DbHelper.AccountStore.Update("AllowModes,FastExhausted,CoreSize", Account);
_discordInstance?.ClearAccountCache(Account.Id);

// 如果开启自动切换慢速模式
Expand Down Expand Up @@ -1078,6 +1083,7 @@ public void OnMessage(JsonElement raw)
|| title.Contains("error")
|| title.Contains("denied"))
{

if (data.TryGetProperty("nonce", out JsonElement noneEle))
{
var nonce = noneEle.GetString();
Expand All @@ -1087,6 +1093,39 @@ public void OnMessage(JsonElement raw)
var task = _discordInstance.GetRunningTaskByNonce(nonce);
if (task != null)
{
// 需要用户同意 Tos
if (title.Contains("Tos not accepted"))
{
try
{
var tosData = data.Deserialize<EventData>();
var customId = tosData?.Components?.SelectMany(x => x.Components)
.Where(x => x.Label == "Accept ToS")
.FirstOrDefault()?.CustomId;

if (!string.IsNullOrWhiteSpace(customId))
{
var nonce2 = SnowFlake.NextId();
var tosRes = _discordInstance.ActionAsync(id, customId, tosData.Flags, nonce2, task)
.ConfigureAwait(false).GetAwaiter().GetResult();

if (tosRes?.Code == ReturnCode.SUCCESS)
{
_logger.Information("处理 Tos 成功 {@0}", Account.ChannelId);
return;
}
else
{
_logger.Information("处理 Tos 失败 {@0}, {@1}", Account.ChannelId, tosRes);
}
}
}
catch (Exception ex)
{
_logger.Error(ex, "处理 Tos 异常 {@0}", Account.ChannelId);
}
}

var error = $"{title}, {desc}";

task.MessageId = id;
Expand Down
2 changes: 1 addition & 1 deletion src/Midjourney.Infrastructure/GlobalConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class GlobalConfiguration
/// <summary>
/// 版本号
/// </summary>
public static string Version { get; set; } = "v5.9.5";
public static string Version { get; set; } = "v5.9.6";

/// <summary>
/// 全局配置项
Expand Down

0 comments on commit e22eb6d

Please sign in to comment.