Skip to content

Commit

Permalink
feat(plugins/qqnoteplugin/): 图片使用 Markdown 标记
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyungent committed May 10, 2022
1 parent 27bf839 commit 501c662
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions plugins/QQNotePlugin/QQNotePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ public void OnFriendMessage((Bot s, FriendMessageEvent e) obj, string message, u

#region 图片文件形式
string dirName = Path.GetFileNameWithoutExtension(settingsModel.GitHub.RepoTargetFilePath);
string imageFileName = $"image-{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")} {imageBytes.GetHashCode()}.{imageType}";
string imageHtml = $"<img src=\"{dirName}/{imageFileName}\" />";
// 注意: 图片文件名不能有空格, 否则会导致在 GitHub 无法预览
string imageFileName = $"image-{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}-{imageBytes.GetHashCode()}.{imageType}";
//string imageHtml = $"<img src=\"{dirName}/{imageFileName}\" />";
// Markdown 图片标记 容易不显示
//string imageMd = $"![{Path.GetFileNameWithoutExtension(imageFileName)}]({dirName}/{imageFileName})";
string imageMd = $"![{Path.GetFileNameWithoutExtension(imageFileName)}]({dirName}/{imageFileName})";
imageDic.Add($"{dirName}/{imageFileName}", imageBytes);
fullMessageSb.AppendLine(imageHtml);
//fullMessageSb.AppendLine(imageHtml);
fullMessageSb.AppendLine(imageMd);
#endregion
}
catch (Exception ex)
Expand Down Expand Up @@ -221,7 +223,7 @@ public void OnFriendMessage((Bot s, FriendMessageEvent e) obj, string message, u
}
catch (Exception ex)
{
obj.s.SendFriendMessage(friendUin, "笔记中的图片写入失败:");
obj.s.SendFriendMessage(friendUin, $"{item.Key} 笔记中的图片写入失败:");
obj.s.SendFriendMessage(friendUin, ex.ToString());
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/QQNotePlugin/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"DisplayName": "QQ写笔记",
"Description": "利用 QQ 写笔记 (随笔/零碎知识点)",
"Author": "yiyun",
"Version": "0.1.1",
"Version": "0.1.2",
"SupportedVersions": [ "0.0.1" ]
}

0 comments on commit 501c662

Please sign in to comment.