diff --git a/Theresa3rd-Bot/Business/MYSBusiness.cs b/Theresa3rd-Bot/Business/MYSBusiness.cs
index 8c99fa56..dddca489 100644
--- a/Theresa3rd-Bot/Business/MYSBusiness.cs
+++ b/Theresa3rd-Bot/Business/MYSBusiness.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Theresa3rd_Bot.Cache;
@@ -42,74 +43,91 @@ public MYSBusiness()
///
public async Task subscribeMYSUserAsync(IMiraiHttpSession session, IGroupMessageEventArgs args, string message)
{
- MysSectionType? mysSection = null;
- string userId = null;
-
- string[] paramArr = message.splitParam(BotConfig.SubscribeConfig.Mihoyo.AddCommand);
- if (paramArr == null || paramArr.Length < 2)
- {
- StepInfo stepInfo = await StepCache.CreateStepAsync(session, args);
- if (stepInfo == null) return;
- StepDetail sectionStep = new StepDetail(60, $" 请在60秒内发送数字选择你要订阅的频道:\r\n{EnumHelper.MysSectionOption()}", CheckSectionAsync);
- StepDetail uidStep = new StepDetail(60, " 请在60秒内发送要订阅用户的id", CheckUserIdAsync);
- stepInfo.AddStep(sectionStep);
- stepInfo.AddStep(uidStep);
- bool isSuccess = await stepInfo.StartStep(session, args);
- if (isSuccess == false) return;
- mysSection = (MysSectionType)Convert.ToInt32(sectionStep.Answer);
- userId = uidStep.Answer;
- }
- else
+ try
{
- if (await CheckSectionAsync(session, args, paramArr[0]) == false) return;
- if (await CheckUserIdAsync(session, args, paramArr[1]) == false) return;
- mysSection = (MysSectionType)Convert.ToInt32(paramArr[0]);
- userId = paramArr[1];
- }
+ MysSectionType? mysSection = null;
+ string userId = null;
- MysResult userInfoDto = await geMysUserFullInfoDtoAsync(userId, (int)mysSection.Value);
- if (userInfoDto == null || userInfoDto.retcode != 0)
- {
- await session.SendMessageWithAtAsync(args, new PlainMessage(" 订阅失败,目标用户不存在"));
- return;
- }
+ string[] paramArr = message.splitParam(BotConfig.SubscribeConfig.Mihoyo.AddCommand);
+ if (paramArr == null || paramArr.Length == 0)
+ {
+ StepInfo stepInfo = await StepCache.CreateStepAsync(session, args);
+ if (stepInfo == null) return;
+ StepDetail uidStep = new StepDetail(60, " 请在60秒内发送要订阅用户的id", CheckUserIdAsync);
+ StepDetail sectionStep = new StepDetail(60, $" 请在60秒内发送数字选择你要订阅的频道:\r\n{EnumHelper.MysSectionOption()}", CheckSectionAsync);
+ stepInfo.AddStep(uidStep);
+ stepInfo.AddStep(sectionStep);
+ bool isSuccess = await stepInfo.StartStep(session, args);
+ if (isSuccess == false) return;
+ userId = uidStep.Answer;
+ mysSection = (MysSectionType)Convert.ToInt32(sectionStep.Answer);
+ }
+ else
+ {
+ userId = paramArr.Length > 0 ? paramArr[0] : null;
+ string mysSectionStr = paramArr.Length > 1 ? paramArr[1] : "0";
+ if (await CheckUserIdAsync(session, args, userId) == false) return;
+ if (await CheckSectionAsync(session, args, mysSectionStr) == false) return;
+ mysSection = (MysSectionType)Convert.ToInt32(mysSectionStr);
+ }
- SubscribePO dbSubscribe = subscribeDao.getSubscribe(userId, SubscribeType.米游社用户, (int)mysSection.Value);
- if (dbSubscribe == null)
- {
- //添加订阅
- dbSubscribe = new SubscribePO();
- dbSubscribe.SubscribeCode = userId;
- dbSubscribe.SubscribeName = StringHelper.filterEmoji(userInfoDto.data.user_info.nickname);
- dbSubscribe.SubscribeDescription = userInfoDto.data.user_info.introduce;
- dbSubscribe.SubscribeType = SubscribeType.米游社用户;
- dbSubscribe.SubscribeSubType = (int)mysSection.Value;
- dbSubscribe.Isliving = false;
- dbSubscribe.CreateDate = DateTime.Now;
- dbSubscribe = subscribeDao.Insert(dbSubscribe);
- }
+ MysResult userInfoDto = await geMysUserFullInfoDtoAsync(userId, (int)mysSection.Value);
+ if (userInfoDto == null || userInfoDto.retcode != 0)
+ {
+ await session.SendMessageWithAtAsync(args, new PlainMessage(" 订阅失败,目标用户不存在"));
+ return;
+ }
- if (subscribeGroupDao.getCountBySubscribe(args.Sender.Group.Id, dbSubscribe.Id) > 0)
- {
- //关联订阅
- await session.SendMessageWithAtAsync(args, new PlainMessage($" 米游社用户[{userId}]已经被订阅了~"));
- return;
- }
+ SubscribePO fullSubscribe = subscribeDao.getSubscribe(userId, SubscribeType.米游社用户, (int)MysSectionType.全部);
+ if (fullSubscribe != null && subscribeGroupDao.getCountBySubscribe(args.Sender.Group.Id, fullSubscribe.Id) > 0)
+ {
+ await session.SendMessageWithAtAsync(args, new PlainMessage($" 已订阅了米游社用户[{userId}]的[{Enum.GetName(typeof(MysSectionType), MysSectionType.全部)}]频道~"));
+ return;
+ }
- SubscribeGroupPO subscribeGroup = new SubscribeGroupPO();
- subscribeGroup.GroupId = args.Sender.Group.Id;
- subscribeGroup.SubscribeId = dbSubscribe.Id;
- subscribeGroup = subscribeGroupDao.Insert(subscribeGroup);
+ SubscribePO dbSubscribe = subscribeDao.getSubscribe(userId, SubscribeType.米游社用户, (int)mysSection.Value);
+ if (dbSubscribe == null)
+ {
+ //添加订阅
+ dbSubscribe = new SubscribePO();
+ dbSubscribe.SubscribeCode = userId;
+ dbSubscribe.SubscribeName = StringHelper.filterEmoji(userInfoDto.data.user_info.nickname)?.filterEmoji().cutString(50);
+ dbSubscribe.SubscribeDescription = userInfoDto.data.user_info.introduce?.filterEmoji().cutString(200);
+ dbSubscribe.SubscribeType = SubscribeType.米游社用户;
+ dbSubscribe.SubscribeSubType = (int)mysSection.Value;
+ dbSubscribe.Isliving = false;
+ dbSubscribe.CreateDate = DateTime.Now;
+ dbSubscribe = subscribeDao.Insert(dbSubscribe);
+ }
- List chailList = new List();
- chailList.Add(new PlainMessage($"米游社用户[{dbSubscribe.SubscribeName}]订阅成功!\r\n"));
- chailList.Add(new PlainMessage($"uid:{dbSubscribe.SubscribeCode}\r\n"));
- chailList.Add(new PlainMessage($"频道:{Enum.GetName(typeof(MysSectionType), mysSection)}\r\n"));
- chailList.Add(new PlainMessage($"签名:{dbSubscribe.SubscribeDescription}\r\n"));
- FileInfo fileInfo = string.IsNullOrEmpty(userInfoDto.data.user_info.avatar_url) ? null : await HttpHelper.DownImgAsync(userInfoDto.data.user_info.avatar_url);
- if (fileInfo != null) chailList.Add((IChatMessage)await MiraiHelper.Session.UploadPictureAsync(UploadTarget.Group, fileInfo.FullName));
- await session.SendMessageWithAtAsync(args, chailList);
- ConfigHelper.loadSubscribeTask();
+ if (subscribeGroupDao.getCountBySubscribe(args.Sender.Group.Id, dbSubscribe.Id) > 0)
+ {
+ await session.SendMessageWithAtAsync(args, new PlainMessage($" 已订阅了米游社用户[{userId}]的[{Enum.GetName(typeof(MysSectionType), MysSectionType.全部)}]频道~"));
+ return;
+ }
+
+ if (mysSection.Value == MysSectionType.全部) delAllSubscribe(args.Sender.Group.Id, userId);
+
+ SubscribeGroupPO subscribeGroup = new SubscribeGroupPO();
+ subscribeGroup.GroupId = args.Sender.Group.Id;
+ subscribeGroup.SubscribeId = dbSubscribe.Id;
+ subscribeGroup = subscribeGroupDao.Insert(subscribeGroup);
+
+ List chailList = new List();
+ chailList.Add(new PlainMessage($"米游社用户[{dbSubscribe.SubscribeName}]订阅成功!\r\n"));
+ chailList.Add(new PlainMessage($"uid:{dbSubscribe.SubscribeCode}\r\n"));
+ chailList.Add(new PlainMessage($"频道:{Enum.GetName(typeof(MysSectionType), mysSection)}\r\n"));
+ chailList.Add(new PlainMessage($"签名:{dbSubscribe.SubscribeDescription}\r\n"));
+ FileInfo fileInfo = string.IsNullOrEmpty(userInfoDto.data.user_info.avatar_url) ? null : await HttpHelper.DownImgAsync(userInfoDto.data.user_info.avatar_url);
+ if (fileInfo != null) chailList.Add((IChatMessage)await MiraiHelper.Session.UploadPictureAsync(UploadTarget.Group, fileInfo.FullName));
+ await session.SendMessageWithAtAsync(args, chailList);
+ ConfigHelper.loadSubscribeTask();
+ }
+ catch(Exception ex)
+ {
+ LogHelper.Error(ex, "订阅米游社用户异常");
+ throw;
+ }
}
///
@@ -123,62 +141,113 @@ public async Task cancleSubscribeMysUserAsync(IMiraiHttpSession session, IGroupM
{
try
{
- string keyWord = message.splitKeyWord(BotConfig.SubscribeConfig.Mihoyo.RmCommand);
- if (string.IsNullOrEmpty(keyWord))
- {
- await session.SendMessageWithAtAsync(args, new PlainMessage(" 没有检测到用户id,请确保指令格式正确"));
- return;
- }
- if (StringHelper.isPureNumber(keyWord) == false)
+ MysSectionType? mysSection = null;
+ string userId = null;
+
+ string[] paramArr = message.splitParam(BotConfig.SubscribeConfig.Mihoyo.RmCommand);
+ if (paramArr == null || paramArr.Length == 0)
{
- await session.SendMessageWithAtAsync(args, new PlainMessage(" 用户id必须为纯数字"));
- return;
+ StepInfo stepInfo = await StepCache.CreateStepAsync(session, args);
+ if (stepInfo == null) return;
+ StepDetail uidStep = new StepDetail(60, " 请在60秒内发送要退订用户的id", CheckUserIdAsync);
+ StepDetail sectionStep = new StepDetail(60, CancleSectionQuestion, CheckSectionAsync);
+ stepInfo.AddStep(uidStep);
+ stepInfo.AddStep(sectionStep);
+ bool isSuccess = await stepInfo.StartStep(session, args);
+ if (isSuccess == false) return;
+ userId = uidStep.Answer;
+ mysSection = (MysSectionType)Convert.ToInt32(sectionStep.Answer);
}
- SubscribePO dbSubscribe = subscribeDao.getSubscribe(keyWord, SubscribeType.米游社用户);
- if (dbSubscribe == null)
+ else
{
- await session.SendMessageWithAtAsync(args, new PlainMessage(" 并没有订阅这个用户哦~"));
- return;
+ userId = paramArr.Length > 0 ? paramArr[0] : null;
+ string mysSectionStr = paramArr.Length > 1 ? paramArr[1] : "0";
+ if (await CheckUserIdAsync(session, args, userId) == false) return;
+ if (await CheckSectionAsync(session, args, mysSectionStr) == false) return;
+ mysSection = (MysSectionType)Convert.ToInt32(mysSectionStr);
}
- bool isGroupSubscribed = subscribeGroupDao.getCountBySubscribe(args.Sender.Group.Id, dbSubscribe.Id) > 0;
- if (isGroupSubscribed == false)
+
+ List subscribeList = getSubscribeList(args.Sender.Group.Id, userId);
+ if (subscribeList == null || subscribeList.Count == 0)
{
await session.SendMessageWithAtAsync(args, new PlainMessage(" 并没有订阅这个用户哦~"));
return;
}
- int successCount = subscribeGroupDao.delSubscribe(args.Sender.Group.Id, dbSubscribe.Id);
- if (successCount == 0)
+
+ foreach (var item in subscribeList)
{
- await session.SendMessageWithAtAsync(args, new PlainMessage(" 退订失败"));
- return;
+ if (mysSection.Value == MysSectionType.全部 || (int)mysSection.Value == item.SubscribeSubType)
+ {
+ subscribeGroupDao.delSubscribe(args.Sender.Group.Id, item.Id);
+ }
}
+
await session.SendMessageWithAtAsync(args, new PlainMessage(" 退订成功~"));
ConfigHelper.loadSubscribeTask();
}
catch (Exception ex)
{
- LogHelper.Error(ex, "退订异常");
+ LogHelper.Error(ex, "退订米游社用户异常");
throw;
}
}
- private async Task CheckSectionAsync(IMiraiHttpSession session, IGroupMessageEventArgs args, string value)
+ ///
+ /// 获取某个群已订阅的列表
+ ///
+ ///
+ ///
+ ///
+ public List getSubscribeList(long groupId, string subscribeCode)
{
- int sectionType = 0;
- if (int.TryParse(value, out sectionType) == false)
+ List subscribeList = new List();
+ List dbSubscribes = subscribeDao.getSubscribes(subscribeCode, SubscribeType.米游社用户);
+ if (dbSubscribes == null || dbSubscribes.Count == 0) return subscribeList;
+ foreach (var item in dbSubscribes)
{
- await session.SendMessageWithAtAsync(args, new PlainMessage(" 频道必须为数字"));
- return false;
+ if (subscribeGroupDao.getCountBySubscribe(groupId, item.Id) == 0) continue;
+ subscribeList.Add(item);
+ }
+ return subscribeList;
+ }
+
+ ///
+ /// 删除一个订阅编码下的所有订阅
+ ///
+ ///
+ ///
+ public void delAllSubscribe(long groupId, string subscribeCode)
+ {
+ List dbSubscribes = subscribeDao.getSubscribes(subscribeCode, SubscribeType.米游社用户);
+ foreach (var item in dbSubscribes) subscribeGroupDao.delSubscribe(groupId, item.Id);
+ }
+
+
+ private async Task CancleSectionQuestion(IMiraiHttpSession session, IGroupMessageEventArgs args, StepInfo stepInfo, StepDetail currentStep)
+ {
+ string userIdstr = stepInfo.StepDetails[0].Answer;
+ List subscribeList = getSubscribeList(args.Sender.Group.Id, userIdstr);
+ if (subscribeList == null || subscribeList.Count == 0)
+ {
+ await session.SendMessageWithAtAsync(args, new PlainMessage(" 并没有订阅这个用户哦~"));
+ return null;
}
- if (Enum.IsDefined(typeof(MysSectionType), sectionType) == false)
+
+ StringBuilder questionBuilder = new StringBuilder();
+ questionBuilder.AppendLine($"请在{currentStep.WaitSecond}秒内发送数字选择你要退订的频道:");
+ questionBuilder.AppendLine($"{(int)MysSectionType.全部}:{Enum.GetName(typeof(MysSectionType), MysSectionType.全部)}");
+ foreach (var item in subscribeList)
{
- await session.SendMessageWithAtAsync(args, new PlainMessage(" 频道不在范围内"));
- return false;
+ if (item.SubscribeSubType == (int)MysSectionType.全部) continue;
+ if (Enum.IsDefined(typeof(MysSectionType), item.SubscribeSubType) == false) continue;
+ MysSectionType mysSectionType = (MysSectionType)item.SubscribeSubType;
+ questionBuilder.AppendLine($"{item.SubscribeSubType}:{Enum.GetName(typeof(MysSectionType), mysSectionType)}");
}
- return true;
+ return questionBuilder.ToString();
}
+
private async Task CheckUserIdAsync(IMiraiHttpSession session, IGroupMessageEventArgs args, string value)
{
long userId = 0;
@@ -196,41 +265,70 @@ private async Task CheckUserIdAsync(IMiraiHttpSession session, IGroupMessa
}
+ private async Task CheckSectionAsync(IMiraiHttpSession session, IGroupMessageEventArgs args, string value)
+ {
+ int sectionId = 0;
+ if (int.TryParse(value, out sectionId) == false)
+ {
+ await session.SendMessageWithAtAsync(args, new PlainMessage(" 频道必须为数字"));
+ return false;
+ }
+ if (Enum.IsDefined(typeof(MysSectionType), sectionId) == false)
+ {
+ await session.SendMessageWithAtAsync(args, new PlainMessage(" 频道不在范围内"));
+ return false;
+ }
+ return true;
+ }
+
+
public async Task> getMysUserSubscribeAsync(SubscribeInfo subscribeInfo, int getCount = 2)
{
- int index = 0;
List mysSubscribeList = new List();
- MysResult mysPostInfo = await getMysUserPostDtoAsync(subscribeInfo.SubscribeCode, subscribeInfo.SubscribeSubType);
- List postList = mysPostInfo.data.list;
- if (postList.Count == 0) return mysSubscribeList;
- foreach (var item in postList)
+ List> postDataList = new List>();
+ foreach (var item in Enum.GetValues(typeof(MysSectionType)))
{
- if (++index > getCount) break;
- int shelfLife = BotConfig.SubscribeConfig.Mihoyo.ShelfLife;
- DateTime createTime = DateTimeHelper.UnixTimeStampToDateTime(item.post.created_at);
- if (shelfLife > 0 && createTime < DateTime.Now.AddSeconds(-1 * shelfLife)) continue;
-
- SubscribeRecordPO subscribeRecord = new SubscribeRecordPO(subscribeInfo.SubscribeId);
- subscribeRecord.Title = item.post.subject.cutString(200);
- subscribeRecord.Content = item.post.content.cutString(500);
- subscribeRecord.CoverUrl = item.post.images.Count > 0 ? item.post.images[0] : "";
- subscribeRecord.LinkUrl = HttpUrl.getMysArticleUrl(item.post.post_id);
- subscribeRecord.DynamicCode = item.post.post_id;
- subscribeRecord.DynamicType = SubscribeDynamicType.帖子;
-
- SubscribeRecordPO dbSubscribe = subscribeRecordDao.checkExists(subscribeInfo.SubscribeId, item.post.post_id);
- if (dbSubscribe != null) continue;
-
- MysSubscribe mysSubscribe = new MysSubscribe();
- mysSubscribe.SubscribeRecord = subscribeRecordDao.Insert(subscribeRecord);
- mysSubscribe.MysUserPostDto = item;
- mysSubscribe.CreateTime = createTime;
- mysSubscribeList.Add(mysSubscribe);
+ int typeId = (int)item;
+ if (typeId == (int)MysSectionType.全部) continue;
+ if (subscribeInfo.SubscribeSubType != (int)MysSectionType.全部 && subscribeInfo.SubscribeSubType != typeId) continue;
+ postDataList.Add(await getMysUserPostDtoAsync(subscribeInfo.SubscribeCode, typeId));
await Task.Delay(1000);
}
+
+ foreach (var mysPostInfo in postDataList)
+ {
+ int index = 0;
+ if (mysPostInfo.data.list == null || mysPostInfo.data.list.Count == 0) continue;
+ foreach (var item in mysPostInfo.data.list)
+ {
+ if (++index > getCount) break;
+ int shelfLife = BotConfig.SubscribeConfig.Mihoyo.ShelfLife;
+ DateTime createTime = DateTimeHelper.UnixTimeStampToDateTime(item.post.created_at);
+ if (shelfLife > 0 && createTime < DateTime.Now.AddSeconds(-1 * shelfLife)) continue;
+
+ SubscribeRecordPO subscribeRecord = new SubscribeRecordPO(subscribeInfo.SubscribeId);
+ subscribeRecord.Title = item.post.subject?.filterEmoji().cutString(200);
+ subscribeRecord.Content = item.post.content?.filterEmoji().cutString(500);
+ subscribeRecord.CoverUrl = item.post.images.Count > 0 ? item.post.images[0] : "";
+ subscribeRecord.LinkUrl = HttpUrl.getMysArticleUrl(item.post.post_id);
+ subscribeRecord.DynamicCode = item.post.post_id;
+ subscribeRecord.DynamicType = SubscribeDynamicType.帖子;
+
+ SubscribeRecordPO dbSubscribe = subscribeRecordDao.checkExists(subscribeInfo.SubscribeId, item.post.post_id);
+ if (dbSubscribe != null) continue;
+
+ MysSubscribe mysSubscribe = new MysSubscribe();
+ mysSubscribe.SubscribeRecord = subscribeRecordDao.Insert(subscribeRecord);
+ mysSubscribe.MysUserPostDto = item;
+ mysSubscribe.CreateTime = createTime;
+ mysSubscribeList.Add(mysSubscribe);
+ await Task.Delay(1000);
+ }
+ }
return mysSubscribeList;
}
+
public async Task> getSubscribeInfoAsync(MysSubscribe mysSubscribe, string template = "")
{
if (string.IsNullOrWhiteSpace(template)) return await getDefaultSubscribeInfoAsync(mysSubscribe);
@@ -246,6 +344,7 @@ public async Task> getSubscribeInfoAsync(MysSubscribe mysSubs
return chailList;
}
+
public async Task> getDefaultSubscribeInfoAsync(MysSubscribe mysSubscribe)
{
List chailList = new List();
@@ -265,6 +364,7 @@ public async Task> getDefaultPostInfoAsync(MysSubscribe mysSu
return chailList;
}
+
private async Task> getMysUserPostDtoAsync(string userId, int gids)
{
Dictionary headerDic = new Dictionary();
@@ -273,6 +373,7 @@ private async Task> getMysUserPostDtoAsync(string user
return JsonConvert.DeserializeObject>(json);
}
+
private async Task> geMysUserFullInfoDtoAsync(string userId, int gids)
{
Dictionary headerDic = new Dictionary();
diff --git a/Theresa3rd-Bot/Dao/SubscribeDao.cs b/Theresa3rd-Bot/Dao/SubscribeDao.cs
index 97a73ab6..bb70ab32 100644
--- a/Theresa3rd-Bot/Dao/SubscribeDao.cs
+++ b/Theresa3rd-Bot/Dao/SubscribeDao.cs
@@ -20,7 +20,6 @@ public List getSubscribeInfo()
public SubscribePO getSubscribe(string subscribeCode, SubscribeType subscribeType)
{
- string sql = Db.Queryable().Where(o => o.SubscribeCode == subscribeCode && o.SubscribeType == subscribeType).ToSqlString();
return Db.Queryable().Where(o => o.SubscribeCode == subscribeCode && o.SubscribeType == subscribeType).First();
}
@@ -29,6 +28,10 @@ public SubscribePO getSubscribe(string subscribeCode, SubscribeType subscribeTyp
return Db.Queryable().Where(o => o.SubscribeCode == subscribeCode && o.SubscribeType == subscribeType && o.SubscribeSubType == subscribeSubType).First();
}
+ public List getSubscribes(string subscribeCode, SubscribeType subscribeType)
+ {
+ return Db.Queryable().Where(o => o.SubscribeCode == subscribeCode && o.SubscribeType == subscribeType).OrderBy(o => o.SubscribeSubType).ToList();
+ }
}
}
diff --git a/Theresa3rd-Bot/Model/Cache/StepDetail.cs b/Theresa3rd-Bot/Model/Cache/StepDetail.cs
index 39e28424..77da07e5 100644
--- a/Theresa3rd-Bot/Model/Cache/StepDetail.cs
+++ b/Theresa3rd-Bot/Model/Cache/StepDetail.cs
@@ -22,6 +22,8 @@ public class StepDetail
public Func> CheckInput { get; set; }
+ public Func> StepQuestion { get; set; }
+
public StepDetail(int waitSecond, string question, Func> checkInput = null)
{
this.WaitSecond = waitSecond;
@@ -29,6 +31,16 @@ public StepDetail(int waitSecond, string question, Func> stepQuestion,
+ Func> checkInput = null)
+ {
+ this.WaitSecond = waitSecond;
+ this.StepQuestion = stepQuestion;
+ this.CheckInput = checkInput;
+ }
+
public bool IsTimeout()
{
if (StartTime == null) return false;
@@ -44,7 +56,7 @@ public void StartStep()
public void FinishStep(IGroupMessageEventArgs args, string answer)
{
this.Args = args;
- this.Answer = answer;
+ this.Answer = answer?.Trim();
this.IsFinish = true;
}
diff --git a/Theresa3rd-Bot/Model/Cache/StepInfo.cs b/Theresa3rd-Bot/Model/Cache/StepInfo.cs
index 99ffc9f6..e043ceca 100644
--- a/Theresa3rd-Bot/Model/Cache/StepInfo.cs
+++ b/Theresa3rd-Bot/Model/Cache/StepInfo.cs
@@ -45,7 +45,14 @@ public Task StartStep(IMiraiHttpSession session, IGroupMessageEventArgs ar
StepDetail stepDetail = StepDetails[i];
if (stepDetail.IsFinish) continue;
if (stepDetail.StartTime == null) stepDetail.StartStep();
+ if (stepDetail.StepQuestion != null)
+ {
+ stepDetail.Question = await stepDetail.StepQuestion(session, args, this, stepDetail);
+ if (string.IsNullOrEmpty(stepDetail.Question)) return false;
+ }
+
await session.SendMessageWithAtAsync(args, new PlainMessage(stepDetail.Question));
+
while (true)
{
if (stepDetail.IsFinish) break;
diff --git a/Theresa3rd-Bot/Timer/MysUserTimer.cs b/Theresa3rd-Bot/Timer/MysUserTimer.cs
index d63d9e29..8193f655 100644
--- a/Theresa3rd-Bot/Timer/MysUserTimer.cs
+++ b/Theresa3rd-Bot/Timer/MysUserTimer.cs
@@ -75,7 +75,18 @@ private static async Task sendGroupSubscribeAsync(MYSBusiness mysBusiness, Subsc
List chailList = await mysBusiness.getSubscribeInfoAsync(mysSubscribe, BotConfig.SubscribeConfig.Mihoyo.Template);
foreach (long groupId in subscribeTask.GroupIdList)
{
- await MiraiHelper.Session.SendGroupMessageAsync(groupId, chailList.ToArray());
+ try
+ {
+ await MiraiHelper.Session.SendGroupMessageAsync(groupId, chailList.ToArray());
+ }
+ catch (Exception ex)
+ {
+ LogHelper.Error(ex, "米游社订阅消息发送失败");
+ }
+ finally
+ {
+ await Task.Delay(1000);
+ }
}
}
}
diff --git a/Theresa3rd-Bot/Timer/PixivTagTimer.cs b/Theresa3rd-Bot/Timer/PixivTagTimer.cs
index 2296e350..af6f6341 100644
--- a/Theresa3rd-Bot/Timer/PixivTagTimer.cs
+++ b/Theresa3rd-Bot/Timer/PixivTagTimer.cs
@@ -100,7 +100,18 @@ private static async Task sendGroupSubscribeAsync(SubscribeTask subscribeTask, L
}
foreach (long groupId in subscribeTask.GroupIdList)
{
- await MiraiHelper.Session.SendGroupMessageAsync(groupId, chailList.ToArray());
+ try
+ {
+ await MiraiHelper.Session.SendGroupMessageAsync(groupId, chailList.ToArray());
+ }
+ catch (Exception ex)
+ {
+ LogHelper.Error(ex, "pixiv标签订阅消息发送失败");
+ }
+ finally
+ {
+ await Task.Delay(1000);
+ }
}
}
}
diff --git a/Theresa3rd-Bot/Timer/PixivUserTimer.cs b/Theresa3rd-Bot/Timer/PixivUserTimer.cs
index e002216b..e5f2653e 100644
--- a/Theresa3rd-Bot/Timer/PixivUserTimer.cs
+++ b/Theresa3rd-Bot/Timer/PixivUserTimer.cs
@@ -99,7 +99,18 @@ private static async Task sendGroupSubscribeAsync(SubscribeTask subscribeTask, L
}
foreach (long groupId in subscribeTask.GroupIdList)
{
- await MiraiHelper.Session.SendGroupMessageAsync(groupId, chailList.ToArray());
+ try
+ {
+ await MiraiHelper.Session.SendGroupMessageAsync(groupId, chailList.ToArray());
+ }
+ catch (Exception ex)
+ {
+ LogHelper.Error(ex, "pixiv画师订阅消息发送失败");
+ }
+ finally
+ {
+ await Task.Delay(1000);
+ }
}
}
}
diff --git a/Theresa3rd-Bot/Type/MysSectionType.cs b/Theresa3rd-Bot/Type/MysSectionType.cs
index 47474639..94584643 100644
--- a/Theresa3rd-Bot/Type/MysSectionType.cs
+++ b/Theresa3rd-Bot/Type/MysSectionType.cs
@@ -2,7 +2,7 @@
{
public enum MysSectionType
{
- 其他 = 0,
+ 全部 = 0,
崩坏3 = 1,
原神 = 2,
崩坏2 = 3,
diff --git a/Theresa3rd-Bot/Util/EnumHelper.cs b/Theresa3rd-Bot/Util/EnumHelper.cs
index fba9ae27..9a1d6ea3 100644
--- a/Theresa3rd-Bot/Util/EnumHelper.cs
+++ b/Theresa3rd-Bot/Util/EnumHelper.cs
@@ -10,6 +10,7 @@ public static class EnumHelper
public static string MysSectionOption()
{
StringBuilder optionBuilder=new StringBuilder();
+ optionBuilder.AppendLine($"{(int)MysSectionType.全部}:{Enum.GetName(typeof(MysSectionType), MysSectionType.全部)}");
optionBuilder.AppendLine($"{(int)MysSectionType.崩坏3}:{Enum.GetName(typeof(MysSectionType), MysSectionType.崩坏3)}");
optionBuilder.AppendLine($"{(int)MysSectionType.原神}:{Enum.GetName(typeof(MysSectionType), MysSectionType.原神)}");
optionBuilder.AppendLine($"{(int)MysSectionType.崩坏2}:{Enum.GetName(typeof(MysSectionType), MysSectionType.崩坏2)}");