Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
[PR] #53 CrazyKidCN - "图片"消息组件兼容发送本地路径的图片
Browse files Browse the repository at this point in the history
"图片"消息组件兼容发送本地路径的图片
  • Loading branch information
hykilpikonna authored Dec 28, 2020
2 parents be135a6 + 550e274 commit c54200b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cc.moecraft.icq.sender.message.components;

import cc.moecraft.icq.sender.message.MessageComponent;
import lombok.AllArgsConstructor;

/**
* 此类由 Hykilpikonna 在 2018/05/26 创建!
Expand All @@ -11,14 +10,27 @@
*
* @author Hykilpikonna
*/
@AllArgsConstructor
public class ComponentImage extends MessageComponent
{
public String fileOrURL;
public boolean isLocalFile;

public ComponentImage(String fileOrURL) {
this.fileOrURL = fileOrURL;
}

public ComponentImage(String fileOrURL, boolean isLocalFile) {
this.fileOrURL = fileOrURL;
this.isLocalFile = isLocalFile;
}

@Override
public String toString()
{
return "[CQ:image,file=" + fileOrURL + "]";
if (isLocalFile) {
return "[CQ:image,file=file:///" + fileOrURL + "]";
} else {
return "[CQ:image,file=" + fileOrURL + "]";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ public ComponentImageNoCache(String fileOrURL)
super(fileOrURL);
}

public ComponentImageNoCache(String fileOrURL, boolean isLocalFile) {
super(fileOrURL, isLocalFile);
}

@Override
public String toString()
{
return "[CQ:image,cache=0,file=" + super.fileOrURL + "]";
if (isLocalFile) {
return "[CQ:image,cache=0,file=file:///" + super.fileOrURL + "]";
} else {
return "[CQ:image,cache=0,file=" + super.fileOrURL + "]";
}
}
}

0 comments on commit c54200b

Please sign in to comment.