Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

稀にユーザ情報が取得できない場合があり取得出来ないとコメントすら表示されなくなるので回避 #195

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions NicoSitePlugin2/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public static async Task<UserInfo> GetUserInfo(IDataSource server, CookieContain
var res = await server.GetAsync(url, cc);
var obj = JsonConvert.DeserializeObject<NicoSitePlugin2.Low.UserInfo.RootObject>(res);
if (obj.Data.Length == 0)
{
throw new ArgumentException("指定されたuserIdは存在しない:" + userId);
}
return null;
var data = obj.Data[0];
var userInfo = new UserInfo
{
Expand Down
8 changes: 2 additions & 6 deletions NicoSitePlugin2/TestCommentProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,13 @@ private async Task ProcessChatMessageAsync(Chat.IChatMessage message)
{
_chatProvider?.Disconnect();
}
string username;
string username = null;
if (IsRawUserId(chat.UserId) && chat.UserId != SystemUserId && _siteOptions.IsAutoGetUsername)
{
var userInfo = await Api.GetUserInfo(_server, _cc, chat.UserId);
username = userInfo.Nickname;
username = userInfo?.Nickname;
user.Name = Common.MessagePartFactory.CreateMessageItems(username);
}
else
{
username = null;
}
if (_siteOptions.IsAutoSetNickname)
{
var nick = SitePluginCommon.Utils.ExtractNickname(chat.Content);
Expand Down