Skip to content

Commit

Permalink
米游社订阅
Browse files Browse the repository at this point in the history
  • Loading branch information
GardenHamster committed May 24, 2022
1 parent b41b466 commit 8c88c08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Theresa3rd-Bot/Business/MYSBusiness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task subscribeMYSUserAsync(IMiraiHttpSession session, IGroupMessage
{
StepInfo stepInfo = await StepCache.CreateStepAsync(session, args);
if (stepInfo == null) return;
StepDetail sectionStep = new StepDetail(60, $" 请在60秒内发送数字选择你要订阅的版块\r\n{EnumHelper.MysSectionOption()}", CheckSectionAsync);
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);
Expand All @@ -74,7 +74,7 @@ public async Task subscribeMYSUserAsync(IMiraiHttpSession session, IGroupMessage
return;
}

SubscribePO dbSubscribe = subscribeDao.getSubscribe(userId, SubscribeType.米游社用户);
SubscribePO dbSubscribe = subscribeDao.getSubscribe(userId, SubscribeType.米游社用户, (int)mysSection.Value);
if (dbSubscribe == null)
{
//添加订阅
Expand All @@ -101,11 +101,14 @@ public async Task subscribeMYSUserAsync(IMiraiHttpSession session, IGroupMessage
subscribeGroup.SubscribeId = dbSubscribe.Id;
subscribeGroup = subscribeGroupDao.Insert(subscribeGroup);

StringBuilder msgBuilder = new StringBuilder();
msgBuilder.AppendLine($"米游社用户[{dbSubscribe.SubscribeName}]订阅成功!");
msgBuilder.AppendLine($"uid:{dbSubscribe.SubscribeCode}");
msgBuilder.AppendLine($"签名:{dbSubscribe.SubscribeDescription}");
await session.SendMessageWithAtAsync(args, new PlainMessage(msgBuilder.ToString()));
List<IChatMessage> chailList = new List<IChatMessage>();
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();
}

Expand Down Expand Up @@ -154,7 +157,7 @@ public async Task cancleSubscribeMysUserAsync(IMiraiHttpSession session, IGroupM
}
catch (Exception ex)
{
LogHelper.Error(ex, "取消订阅异常");
LogHelper.Error(ex, "退订异常");
throw;
}
}
Expand All @@ -165,12 +168,12 @@ private async Task<bool> CheckSectionAsync(IMiraiHttpSession session, IGroupMess
int sectionType = 0;
if (int.TryParse(value, out sectionType) == false)
{
await session.SendMessageWithAtAsync(args, new PlainMessage(" 版块必须为数字"));
await session.SendMessageWithAtAsync(args, new PlainMessage(" 频道必须为数字"));
return false;
}
if (Enum.IsDefined(typeof(MysSectionType), sectionType) == false)
{
await session.SendMessageWithAtAsync(args, new PlainMessage(" 版块不在范围内"));
await session.SendMessageWithAtAsync(args, new PlainMessage(" 频道不在范围内"));
return false;
}
return true;
Expand Down
2 changes: 2 additions & 0 deletions Theresa3rd-Bot/Model/Mys/MysUserFullInfoDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class MysUserFullInfo
public string introduce { get; set; }

public string uid { get; set; }

public string avatar_url { get; set; }
}

}

0 comments on commit 8c88c08

Please sign in to comment.