Java调用Midjourney进行AI画图原生版抓包实现支持中文

用途介绍

Midjourney是一个目前优秀的AI画图工具,不挂梯无法直接访问

本代码主要用于搭建镜像站使用

适合人群

本代码不适合新手,建议使用过okhttp、且具有二开能力的同学使用~

实现原理

通过调用发送信息接口发送请求,通过轮询房间消息接口判断是否作图完成

发送的时候带上我们存储好的cookie信息即可

轮询房间消息接口是为了避免模拟网页实际的websocket连接,那玩意解密没解出来...

准备

1. 开通Midjourney会员的Discord账号

2. 新建很多房间(因为房间消息接口默认就50条数据,也就是说每个房间最多并行50个图片生成任务)

功能预览

上代码

代码功能:

1. 调用Midjourney生成并将生成好的内容发送微信消息给用户(这个是在微信公众号平台做的,大家做网页版的话自己改下输出到网页就可以)

2. 进行合规性检测(生成点不得了的东西后果你懂得,这里用的是百度的文本审核服务,5万次以下免费)

3. 如果用户输入是中文,就翻译为英文再发送

midjourneyLog

midjourney_log表字段如下代码所示

需要使用通用mapper哦~

package com.example.midjourney.bean.pojo;import lombok.Data;
import tk.mybatis.mapper.annotation.NameStyle;
import tk.mybatis.mapper.code.Style;import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;@Data
@NameStyle(Style.camelhump)
@Table(name = "midjourney_log")
public class MidjourneyLog {@Id@GeneratedValue(strategy = GenerationType.IDENTITY)private Long id;private Integer memberId;private String channel;private String prompt;private Integer type;private Integer status;private String imgFile;private Integer roomId;private String uuid;private Date createTime;}

MidJourneyBiz

请求唯一id没啥规律,一段时间内不一致就行,试了没啥校验

另外请求头除了cookie需要保证和 authorization、x-super-properties对应上,三者对应上实测2个月都不会掉线!

package com.example.midjourney.biz;import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSON;
import com.example.midjourney.bean.BaiduTextCensor;
import com.example.midjourney.bean.BaiduTextCensorData;
import com.example.midjourney.bean.MidMsg;
import com.example.midjourney.bean.pojo.Discord;
import com.example.midjourney.bean.pojo.MidjourneyLog;
import com.example.midjourney.bean.pojo.RoomInfo;
import com.example.midjourney.contant.Constant;
import com.example.midjourney.enums.MedjourneyLogType;
import com.example.midjourney.service.DiscordService;
import com.example.midjourney.service.MidjourneyLogService;
import com.example.midjourney.service.MemberService;
import com.example.midjourney.service.RoomInfoService;
import com.example.midjourney.util.*;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.apache.logging.log4j.util.Strings;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;import static com.example.midjourney.contant.Constant.*;/*** 启动就运行,不停刷新消息列表*/
@Slf4j
@Service
public class MidJourneyBiz {private static BigDecimal bigDecimal = new BigDecimal("1099765990370980513").add(new BigDecimal(System.currentTimeMillis()));@Resourceprivate WeChatBiz weChatBiz;@Resourceprivate TranslateBiz translateBiz;@Resourceprivate MidjourneyLogService midjourneyLogService;@Resourceprivate MemberService memberService;@Resourceprivate RoomInfoService roomInfoService;@Resourceprivate DiscordService discordService;public void buildImg(Long id) {MidjourneyLog midjourneyLog = midjourneyLogService.findById(id);try {if (midjourneyLog.getStatus() != 0) {return;}if (isFailMsg(midjourneyLog.getChannel(), midjourneyLog)) {log.info("[失败提示] 消息校验不通过 log:{}", midjourneyLog);sendBuildFail(midjourneyLog);return;}String prompt = midjourneyLog.getPrompt();if (midjourneyLog.getType() == MedjourneyLogType.BIG_IMG.getCode()) {downImg(midjourneyLog);return;}BaiduTextCensor censor = null;if (TextUtil.isHaveChinese(prompt)) {censor = BaiduUtil.textCensor(prompt);}prompt = cleanMsg(prompt);if (isBlackWord(prompt)) {sendSensitive(midjourneyLog);return;}if (Objects.isNull(censor)) {censor = BaiduUtil.textCensor(prompt);}midjourneyLogService.updatePrompt(midjourneyLog, prompt);if (censor.getConclusionType() == 2 || censor.getConclusionType() == 3) {sendSensitive(midjourneyLog, censor);return;}if (midjourneyLog.getType() == MedjourneyLogType.ITERATIVE.getCode()) {//暂不支持sendBuildFail(midjourneyLog);return;}RoomInfo roomInfo = roomInfoService.findIdleRoom();if (Objects.isNull(roomInfo)) {log.error("[并发超出警报] 当前并发次数已经无法满足!!!");sendBuildFail(midjourneyLog);return;}if (sendMsg(prompt, roomInfo)) {midjourneyLogService.updateRoom(midjourneyLog, roomInfo);} else {log.error("[发送失败] 发送信息失败,请检查");sendBuildFail(midjourneyLog);}} catch (Throwable t) {sendBuildFail(midjourneyLog);}}@SneakyThrowsprivate void downImg(MidjourneyLog midjourneyLog) {MidjourneyLog lastLog = midjourneyLogService.findLastNormalLog(midjourneyLog.getMemberId());log.info("[下载图片] {}", lastLog);if (Objects.isNull(lastLog)) {log.info("[失败提示] 找不到上一次的图片 log:{}", midjourneyLog);sendBuildFail(midjourneyLog);return;}String imgFile = lastLog.getImgFile();File file = new File(imgFile);if (!file.exists()) {log.info("[失败提示] 上一次图片不存在 log:{}", lastLog);sendBuildFail(midjourneyLog);return;}cutAndSendImg(midjourneyLog, file);}private void cutAndSendImg(MidjourneyLog midjourneyLog, File oldFile) throws IOException {BufferedImage bufferedImage = ImageIO.read(new FileInputStream(oldFile));int width = bufferedImage.getWidth();int height = bufferedImage.getHeight();String msg = midjourneyLog.getPrompt().trim();String newFileName;if (msg.equalsIgnoreCase("u1")) {newFileName = oldFile.getPath() + "_u1.png";ImgUtil.cut(oldFile, FileUtil.file(newFileName),new Rectangle(0, 0, width / 2, height / 2));} else if (msg.equalsIgnoreCase("u2")) {newFileName = oldFile.getPath() + "_u2.png";ImgUtil.cut(oldFile, FileUtil.file(newFileName),new Rectangle(width / 2, 0, width / 2, height / 2));} else if (msg.equalsIgnoreCase("u3")) {newFileName = oldFile.getPath() + "_u3.png";ImgUtil.cut(oldFile, FileUtil.file(newFileName),new Rectangle(0, height / 2, width / 2, height / 2));} else if (msg.equalsIgnoreCase("u4")) {newFileName = oldFile.getPath() + "_u4.png";ImgUtil.cut(oldFile, FileUtil.file(newFileName),new Rectangle(width / 2, height / 2, width / 2, height / 2));} else {sendBuildFail(midjourneyLog);return;}String mediaId = weChatBiz.sendImg(newFileName, midjourneyLog.getChannel());log.info("[mediaId] {}", mediaId);if (Strings.isNotEmpty(mediaId)) {String wxId = memberService.selectWxidById(midjourneyLog.getMemberId());if (Strings.isEmpty(wxId)) {sendBuildFail(midjourneyLog);return;}midjourneyLogService.updateFinish(midjourneyLog);weChatBiz.sendImgMsg(wxId, mediaId, midjourneyLog.getChannel());}}private boolean isFailMsg(String channel, MidjourneyLog midjourneyLog) {return Objects.isNull(midjourneyLog) || Strings.isEmpty(midjourneyLog.getPrompt()) || Strings.isEmpty(channel)|| Objects.isNull(midjourneyLog.getMemberId()) || checkNotRunMsg(midjourneyLog);}public boolean checkNotRunMsg(MidjourneyLog midjourneyLog) {String prompt = midjourneyLog.getPrompt();if (midjourneyLog.getType() == MedjourneyLogType.BIG_IMG.getCode()) {return !(prompt.equalsIgnoreCase("u1") || prompt.equalsIgnoreCase("u2")|| prompt.equalsIgnoreCase("u3") || prompt.equalsIgnoreCase("u4"));} else if (midjourneyLog.getType() == MedjourneyLogType.ITERATIVE.getCode()) {return !(prompt.equalsIgnoreCase("v1") || prompt.equalsIgnoreCase("v2")|| prompt.equalsIgnoreCase("v3") || prompt.equalsIgnoreCase("v4"));} else {return false;}}private String cleanMsg(String msg) {msg = msg.replace("—", "--").replace("-- ", "--").replace("-- ", "--").replace("-- ", "--").replace(",", ",").replace("/", "").replace("--v", " --v ").replace("--niji", " --niji ").replace("--ar", " --ar ").replace("--aspect", " --ar ").replace("--chaos", " --chaos ").replace("--c", " --c ").replace("--no", " --no ").replace("--quality", " --quality ").replace("--q", " --q ").replace("--repeat", " --repeat ").replace("--s", " --s ").replace("--upbeta", " --upbeta ").trim();if (TextUtil.isHaveChinese(msg)) {msg = translateBiz.translate(msg);}msg = msg.replace(",", ",").replace("/", "").replace("--v5", " --v 5 ").replace("--niji5", " --niji 5 ").trim();if (!msg.contains("--niji") && !msg.contains("--v") && msg.length() > 3) {msg = msg + " --v 5";}return msg;}public void sendBuildFail(MidjourneyLog midjourneyLog) {String wxId = memberService.selectWxidById(midjourneyLog.getMemberId());CallBackUtil.failCallBack(midjourneyLog.getChannel(), MIDJOURNEY, midjourneyLog.getId());midjourneyLogService.updateFail(midjourneyLog);weChatBiz.sendTextMsg(wxId, "抱歉,您的消息【" + midjourneyLog.getPrompt() + "】处理失败,已为您退换对应电量",midjourneyLog.getChannel());}@Scheduled(cron = "34 * * * * ? ")public void checkImg() {//房间号清理cleanRoomNumber();//查询所有进行中的任务List<MidjourneyLog> logs = midjourneyLogService.selectAllDoing().stream().filter(log -> Objects.nonNull(log.getRoomId())).collect(Collectors.toList());//找到超时任务进行关闭List<MidjourneyLog> failLogs = logs.stream().filter(log -> System.currentTimeMillis() - log.getCreateTime().getTime() > MAX_WAIT_TIME).collect(Collectors.toList());failLogs.forEach(this::sendBuildFail);//剩余任务整理出来房间号logs.removeAll(failLogs);Set<Integer> roomSet = logs.stream().map(MidjourneyLog::getRoomId).collect(Collectors.toSet());//轮询当前进度for (Integer roomId : roomSet) {RoomInfo roomInfo = roomInfoService.findById(roomId);if (Objects.isNull(roomInfo)) {log.error("[room没找到] roomId:{} 没找到对应房间,看一下是不是挂了", roomId);continue;}Discord discord = discordService.findById(roomInfo.getDiscordId());List<MidMsg> midMsgs = readNowList(roomInfo, discord);log.info("[消息列表] {}", midMsgs);checkAndSendMsg(midMsgs, logs, roomInfo);}}private void cleanRoomNumber() {List<RoomInfo> roomInfos = roomInfoService.findAll();for (RoomInfo roomInfo : roomInfos) {int count = midjourneyLogService.selectRoomOnUse(roomInfo.getId());roomInfo.setNowNumber(count);roomInfoService.update(roomInfo);}}private void checkAndSendMsg(List<MidMsg> midMsgs, List<MidjourneyLog> logs, RoomInfo roomInfo) {List<MidjourneyLog> roomLogs = logs.stream().filter(log -> log.getRoomId().equals(roomInfo.getId())).collect(Collectors.toList());midMsgs.stream().filter(this::isPrintOk).forEach(m -> roomLogs.forEach(midjourey -> {if (m.getContent().startsWith(MID_JOURNEY_HEAD + filterHead(midjourey.getPrompt()))) {log.info("[Midjourney 配对] msg:{}  key:{}", m, midjourey.getPrompt());String wxid = memberService.selectWxidById(midjourey.getMemberId());String url = m.getAttachments().get(0).getUrl();String localPath = Constant.FILE_PATH + UUID.randomUUID() + "." + FileUtil.getSuffix(url);ImgDownUtil.getImage(url.replace("https://", "http://"), localPath);localPath = localPath.replace("\\", "/");if ("webp".equals(FileUtil.getSuffix(localPath))) {com.example.midjourney.util.ImgUtil.webpToPng(localPath, localPath + ".png");localPath = localPath + ".png";}String mediaId = weChatBiz.sendImg(localPath, midjourey.getChannel());log.info("[mediaId] {}", mediaId);if (Strings.isNotEmpty(mediaId)) {weChatBiz.sendImgMsg(wxid, mediaId, midjourey.getChannel());weChatBiz.sendTextMsg(wxid, "下载高清大图口令:\n\n☆左上图回复:U1\n\n☆右上图回复:U2" +"\n\n☆左下图回复:U3\n\n☆右下图回复:U4\n\n下载大图也会扣电量哦~", midjourey.getChannel());midjourey.setImgFile(localPath);midjourneyLogService.updateFinish(midjourey);}}}));}private String filterHead(String prompt) {return Lists.newArrayList(Splitter.on("--").split(prompt)).stream().findFirst().orElse("").trim();}private boolean isPrintOk(MidMsg midMsg) {if (Objects.isNull(midMsg)|| Strings.isEmpty(midMsg.getContent())|| !midMsg.getContent().contains(MID_FIND_LEFT)) {return false;}String str = midMsg.getContent().substring(midMsg.getContent().indexOf(MID_FIND_LEFT));return !str.contains("%") && !str.contains("Waiting");}private boolean isBlackWord(String msg) {msg = msg.toLowerCase();for (String s : Constant.MidjourneyBlackWord) {if (msg.contains(s.toLowerCase())) {return true;}}return false;}private void sendSensitive(MidjourneyLog midjourneyLog) {String wxid = memberService.selectWxidById(midjourneyLog.getMemberId());midjourneyLogService.updateSensitive(midjourneyLog);weChatBiz.sendTextMsg(wxid, "【违规提示】输入内容包含违禁词,依法进行屏蔽。", midjourneyLog.getChannel());}/*** 审核不通过通知用户*/private void sendSensitive(MidjourneyLog midjourneyLog, BaiduTextCensor censor) {String reason = Joiner.on("、").join(Safes.of(censor.getData()).stream().map(BaiduTextCensorData::getMsg).collect(Collectors.toList()));reason = Strings.isEmpty(reason) ? "包含敏感信息" : reason;String fullText = "【违规提示】输入内容因 " + reason + " ,依法进行屏蔽。(百度提供审核能力)";String wxid = memberService.selectWxidById(midjourneyLog.getMemberId());midjourneyLogService.updateSensitive(midjourneyLog);weChatBiz.sendTextMsg(wxid, fullText, midjourneyLog.getChannel());}public List<MidMsg> readNowList(RoomInfo roomInfo, Discord discord) {OkHttpClient client = new OkHttpClient().newBuilder().build();Request request = new Request.Builder().url("https://discord.com/api/v9/channels/" + roomInfo.getDiscordChannelId() + "/messages?limit=50").get().addHeader("authority", "discord.com").addHeader("accept", "*/*").addHeader("accept-language", "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6").addHeader("authorization", discord.getAuthorization()).addHeader("cache-control", "no-cache").addHeader("cookie", discord.getCookie()).addHeader("pragma", "no-cache").addHeader("referer", "https://discord.com/channels/" + roomInfo.getDiscordGuildId() +"/" + roomInfo.getDiscordChannelId()).addHeader("sec-ch-ua", "\"Not_A Brand\";v=\"99\", \"Microsoft Edge\";v=\"109\", \"Chromium\";v=\"109\"").addHeader("sec-ch-ua-mobile", "?0").addHeader("sec-ch-ua-platform", "\"Windows\"").addHeader("sec-fetch-dest", "empty").addHeader("sec-fetch-mode", "cors").addHeader("sec-fetch-site", "same-origin").addHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.70").addHeader("x-debug-options", "bugReporterEnabled").addHeader("x-discord-locale", "zh-CN").addHeader("x-super-properties", discord.getSuperProperties()).build();try {Response response = client.newCall(request).execute();String string = Objects.requireNonNull(response.body()).string();response.close();return JSON.parseArray(string, MidMsg.class);} catch (Throwable t) {log.error("[发生意外 读取消息失败] room: {}", roomInfo);}return Lists.newArrayList();}@SneakyThrowspublic boolean sendMsg(String msg, RoomInfo roomInfo) {Discord discord = discordService.findById(roomInfo.getDiscordId());bigDecimal = bigDecimal.add(new BigDecimal(1000));OkHttpClient client = new OkHttpClient().newBuilder().build();RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("payload_json", "{\"type\":2,\"application_id\":\"936929561302675456\"," +"\"guild_id\":\"" + roomInfo.getDiscordGuildId() + "\"," +"\"channel_id\":\"" + roomInfo.getDiscordChannelId() + "\"," +"\"session_id\":\"" + discord.getSessionId() + "\"," +"\"data\":{\"version\":\"1077969938624553050\"," +"\"id\":\"938956540159881230\"," +"\"name\":\"imagine\"," +"\"type\":1,\"options\":[" +"{\"type\":3,\"name\":\"prompt\"," +"\"value\":\"" + TextUtil.cleanString(msg) + "\"}]," +"\"application_command\":" +"{\"id\":\"938956540159881230\",\"application_id\":\"936929561302675456\",\"version\":" +"\"1077969938624553050\",\"default_member_permissions\":null,\"type\":1,\"nsfw\":false," +"\"name\":\"imagine\",\"description\":\"Create images with Midjourney\",\"dm_permission\":true," +"\"contexts\":null,\"options\":[{\"type\":3,\"name\":\"prompt\"," +"\"description\":\"The prompt to imagine\",\"required\":true}]}," +"\"attachments\":[]},\"nonce\":\"" + bigDecimal.toString() + "\"} ").build();Request request = new Request.Builder().url("https://discord.com/api/v9/interactions").method("POST", body).addHeader("authority", "discord.com").addHeader("accept", "*/*").addHeader("accept-language", "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6").addHeader("authorization", discord.getAuthorization()).addHeader("cache-control", "no-cache").addHeader("cookie", discord.getCookie()).addHeader("origin", "https://discord.com").addHeader("pragma", "no-cache").addHeader("referer", "https://discord.com/channels/" + roomInfo.getDiscordGuildId() +"/" + roomInfo.getDiscordChannelId()).addHeader("sec-ch-ua", "\"Not_A Brand\";v=\"99\", \"Microsoft Edge\";v=\"109\", \"Chromium\";v=\"109\"").addHeader("sec-ch-ua-mobile", "?0").addHeader("sec-ch-ua-platform", "\"Windows\"").addHeader("sec-fetch-dest", "empty").addHeader("sec-fetch-mode", "cors").addHeader("sec-fetch-site", "same-origin").addHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.70").addHeader("x-debug-options", "bugReporterEnabled").addHeader("x-discord-locale", "zh-CN").addHeader("x-super-properties", discord.getSuperProperties()).build();Response response = client.newCall(request).execute();if (response.code() == 204) {roomInfoService.addOnce(roomInfo);response.close();return true;}response.close();log.info("[midjourney发消息失败] {}", response.code());return false;}
}

MidjourneyLogService

package com.example.midjourney.service;import com.example.midjourney.bean.pojo.MidjourneyLog;
import com.example.midjourney.bean.pojo.RoomInfo;import java.util.List;public interface MidjourneyLogService {MidjourneyLog findById(Long id);MidjourneyLog findLastNormalLog(Integer memberId);MidjourneyLog findLastNormalOrIterative(Integer memberId);void updateRoom(MidjourneyLog midjourneyLog, RoomInfo roomInfo);List<MidjourneyLog> selectAllDoing();void updateFail(MidjourneyLog midjourneyLog);void updateSensitive(MidjourneyLog midjourneyLog);void updatePrompt(MidjourneyLog midjourneyLog, String prompt);void updateFinish(MidjourneyLog midjourey);int selectRoomOnUse(Integer id);}

MidjourneyLogServiceImpl

package com.example.midjourney.service.impl;import com.example.midjourney.bean.pojo.MidjourneyLog;
import com.example.midjourney.bean.pojo.RoomInfo;
import com.example.midjourney.mapper.MidjourneyLogMapper;
import com.example.midjourney.service.MidjourneyLogService;
import com.example.midjourney.util.Safes;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import java.util.List;@Service
public class MidjourneyLogServiceImpl implements MidjourneyLogService {@Resourceprivate MidjourneyLogMapper midjourneyLogMapper;@Overridepublic MidjourneyLog findById(Long id) {return midjourneyLogMapper.selectByPrimaryKey(id);}@Overridepublic MidjourneyLog findLastNormalLog(Integer memberId) {return midjourneyLogMapper.findLastNormalLog(memberId);}@Overridepublic MidjourneyLog findLastNormalOrIterative(Integer memberId) {return midjourneyLogMapper.findLastNormalOrIterative(memberId);}@Overridepublic void updateRoom(MidjourneyLog midjourneyLog, RoomInfo roomInfo) {midjourneyLog.setRoomId(roomInfo.getId());midjourneyLogMapper.updateByPrimaryKeySelective(midjourneyLog);}@Overridepublic List<MidjourneyLog> selectAllDoing() {MidjourneyLog midjourneyLog = new MidjourneyLog();midjourneyLog.setStatus(0);return Safes.of(midjourneyLogMapper.select(midjourneyLog));}@Overridepublic void updateFail(MidjourneyLog midjourneyLog) {midjourneyLog.setStatus(500);midjourneyLogMapper.updateByPrimaryKeySelective(midjourneyLog);}@Overridepublic void updateSensitive(MidjourneyLog midjourneyLog) {midjourneyLog.setStatus(-1);midjourneyLogMapper.updateByPrimaryKeySelective(midjourneyLog);}@Overridepublic void updatePrompt(MidjourneyLog midjourneyLog, String prompt) {midjourneyLog.setPrompt(prompt);midjourneyLogMapper.updateByPrimaryKeySelective(midjourneyLog);}@Overridepublic void updateFinish(MidjourneyLog midjourey) {midjourey.setStatus(1);midjourneyLogMapper.updateByPrimaryKeySelective(midjourey);}@Overridepublic int selectRoomOnUse(Integer id) {return midjourneyLogMapper.selectRoomOnUse(id);}
}

MidjourneyLogMapper 

这里用了通用mapper插件

package com.example.midjourney.mapper;import com.example.midjourney.bean.pojo.MidjourneyLog;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;public interface MidjourneyLogMapper extends Mapper<MidjourneyLog> {String COLUMN = " id, member_id AS memberId, prompt, channel, type, " +"status, img_file AS imgFile, room_id AS roomId ";@Select("SELECT " + COLUMN + " FROM midjourney_log WHERE member_id = #{memberId} AND type = 0 ORDER BY id DESC LIMIT 1")MidjourneyLog findLastNormalLog(@Param("memberId") Integer memberId);@Select("SELECT " + COLUMN + " FROM midjourney_log WHERE member_id = #{memberId} AND (type = 0 OR type = 2)" +" ORDER BY id DESC LIMIT 1")MidjourneyLog findLastNormalOrIterative(Integer memberId);@Select("SELECT COUNT(*) AS count FROM midjourney_log WHERE room_id = #{id} AND status = 0")Integer selectRoomOnUse(@Param("id") Integer id);}

Constant

常量类可以根据需要自定调整敏感词

敏感词写上审核不过,大家自己想想脑补下吧,各种不好的词都往那个敏感词List里面自己加吧!

 

package com.example.midjourney.contant;import com.example.midjourney.bean.UserInfo;
import com.example.midjourney.biz.WeChatBiz;
import com.example.midjourney.util.BaiduUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;public class Constant {public static ExecutorService threadPool = Executors.newFixedThreadPool(20);public static Map<String, UserInfo> imgWordUserMap = Maps.newConcurrentMap();public static String MID_JOURNEY_HEAD = "**";public static String MID_FIND_LEFT = "** - <";public static String FILE_PATH = "D:\\000img\\";public static String CHATGPT = "chatgpt";public static String MIDJOURNEY = "midjourney";public static final String INSUFFICIENT = "insufficient_quota";public static Map<String, String> WX_TOKEN_CHANNEL = Maps.newHashMap();public static Map<String, String> WX_TOKEN_MAP = Maps.newHashMap();public static String BAIDU_TOKEN = BaiduUtil.queryBaiduToken();public static Map<String, String> CHANNEL_CALL_BACK = Maps.newHashMap();/*** 最大等待时间15分钟*/public static long MAX_WAIT_TIME = 1000 * 60 * 15;public static List<String> MidjourneyBlackWord = Lists.newArrayList("写了审核不过,大家自己发挥想象吧...");}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/48595.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

解决Edge中插件下载失败的问题

解决Edge中插件下载失败的问题 这里写目录标题 解决Edge中插件下载失败的问题以下我给出两种解决办法;1. 修改文件内容&#xff08;源头上&#xff09;1.1首先我们可以打开如下的文件夹&#xff1a;1.2 之后将如下内容复制粘贴到该文件的最后面&#xff1a;1.3 如果是你的登录出…

vue即时通讯,一个很好用的插件

直接上链接&#xff1a;https://github.com/leancloud/js-realtime-sdk/tree/master vue-发起websocket协议 https://github.com/nathantsoi/vue-native-websocket

vue3 + TS 自定义插件-全局message提示插件示例

本文记录 Vue3 ts 实现自定义一个全局插件&#xff0c;用于进行 message 消息提示&#xff0c;所谓全局插件即挂载到 vue 实例上&#xff0c;在 App 的任一子组件中均可通过 app 的实例调用该方法。消息提示功能只是示例主要是记录 Vue3 自定义插件功能的写法。 文件结构&…

用chatGPT高效学习-Vue的组件通信方式有哪些?

Vue 的组件通信方式有以下几种&#xff1a; 父子组件通信&#xff1a;父组件通过 props 向子组件传递数据&#xff0c;子组件通过 $emit 触发事件向父组件传递数据。 子父组件通信&#xff1a;子组件通过 $emit 触发事件向父组件传递数据&#xff0c;父组件通过 v-on 监听子组件…

低代码开发,是程序员的“福”还是“祸”?

编者按&#xff1a;低代码是IT界的新风口&#xff0c;它真的会抢占程序员的生存空间吗&#xff1f;本文带你来扒一扒&#xff01; 风口上的低代码 疫情肆虐下&#xff0c;低代码之火不仅没有熄灭&#xff0c;反而更加如火如荼&#xff0c;相对于传统开发&#xff0c;它的确为人…

中学生应该学会使用计算机作文,网络的利与弊中学生作文

网络的利与弊中学生作文 导语&#xff1a;生理上坏处是辐射&#xff0c;心理上的分为网上不健康内容和游戏&#xff0c;不健康内容你自己想得出来吧。以下是小编为大家收集的网络的利与弊中学生作文&#xff0c;欢迎阅读&#xff01; 网络的利与弊中学生作文(一) 所谓“一日之所…

大数据,是个没有感情的杀手?一文解析大数据时代的利和弊

01 瘆人的大数据 上个月小柒邀请闺蜜们来家喝茶聊天,大家讨论去海边的旅游计划。 聊着聊着,小爱同学突然插话:“我也要去”,吓得我赶紧拔掉了小爱的插头。 姐妹们各回各家,小柒躺下刷手机,今日头条给我推送了刚才讨论的海边民宿,顿时睡意全无…… 周末去上海学习了两…

爱思服务器能不能更新苹果手机系统,苹果手机系统升级带来的利和弊,你知道多少?...

很多手机在使用一段时间后需要系统更新升级&#xff0c;如果你觉得手机老版本出现了延迟卡顿&#xff0c;需要升级新系统才能解决这个问题&#xff0c;相信大部分人都会选择更新升级的。要是原先版本用的很顺手&#xff0c;很流畅的&#xff0c;不想升级更新&#xff0c;然后手…

android6.01升级弊端,手机系统升级带来的利和弊,你知道多少?

原标题&#xff1a;手机系统升级带来的利和弊&#xff0c;你知道多少&#xff1f; 每过一段时间&#xff0c;手机上就会有系统更新提醒&#xff0c;很多朋友会第一时间更新&#xff0c;而有朋友也许会和小编一样&#xff0c;认为“这个版本我用着挺好呀&#xff0c;为什么要更新…

Android开发——项目实例(二)迷你背单词软件(第二版)单词录入、背诵、检测、单词库

软件效果图 源码及apk&#xff1a; 链接&#xff1a;https://pan.baidu.com/s/1UkswUGQmmG6dD2fIp0VtBA 提取码&#xff1a;dbxv 如有想修改但不会的&#xff0c;欢迎私信&#xff0c;有时间的话帮你改。 要是觉得还可以&#xff0c;点个再走吧&#xff01;求求了~

android版本单词熟记APP和单词APP

单词熟记APP 帮助大家解决日常生活中英文问题&#xff0c;在APP上&#xff0c;您可以根据 中文查询 英文单词&#xff0c;也可以根据英文单词查询中文的含义&#xff0c;同时还有每日一练&#xff0c;可以进行练习单词&#xff0c;你还可以进行 类似百度的语音跟读功能。同时&a…

天天背单词--的设计与实现(一)

博客第一天,就用这个背单词软件探探路,经过二十天左右的努力&#xff0c;终于一个还算bug少一点的版本完成了&#xff0c;现在这款应用已在百度91安卓市场上架,毕竟开发者只有我,苦逼到图片都要现学ps自己做,所以维护也并不会太快&#xff0c;至于下载量能有几个人就已经很谢谢…

看图听读拼单词游戏

1&#xff0c;视觉&#xff1a;沉浸式单词应用场景图&#xff1b; 2&#xff0c;例句&#xff1a;有针对性的场景图单词例句&#xff1b; 3&#xff0c;发音&#xff1a;标准英语发音跟读&#xff1b; 4&#xff0c;拼写游戏&#xff1a;游戏是孩子的天性&#xff0c;在游戏中记…

微信背单词小程序——小鸡单词

2018-11-02 更新 UI美化没了 2018-10-30 更新 项目主页背单词微信小程序–小鸡单词 该项目已上架微信小程序市场&#xff0c;可以通过微信搜索“小鸡单词”进行使用 项目介绍 1.根据用户记忆遗忘曲线安排每天的学习计划 2.每天学习的细节比普通背单词程序更详细&#xff0c;用…

在终端里背完你的单词表

打工后没了读书时的激情&#xff0c;总感觉缺了点啥。最早为了寻找慰藉&#xff0c;开始折腾黑苹果&#xff0c;背一些单词啥的&#xff0c;但总是三天打鱼两天晒网&#xff0c;觉得没啥用。也是在百无聊赖的某一天&#xff0c;我看着macOS白底黑字的终端&#xff0c;想&#x…

美国邮政总局发行新邮票庆祝虎年;太仓阿尔卑斯雪世界项目封顶;2022年雅高大中华区将有6家酒店开业 | 美通社头条...

要闻摘要&#xff1a;美国邮政总局发行新邮票庆祝虎年。三亚启动新春假日主题文化旅游季系列活动。太仓阿尔卑斯雪世界项目封顶。南昌万怡酒店正式开业。雅高2022年推出一系列多元化新酒店。亚马逊签约第五届进博会。西门子医疗与全景医学签署战略合作协议。黑芝麻智能与MAXIEY…

全国AI特色中小学榜单发布:北京46家单位入围,上海3家

问耕 发自 凹非寺量子位 出品 | 公众号 QbitAI 去年7月&#xff0c;国务院印发《新一代人工智能发展规划》。 这个规划中要求广泛开展人工智能科普活动&#xff0c;“在中小学阶段设置人工智能相关课程&#xff0c;逐步推广编程教育。” 而中青在线最近在报道中说&#xff1a;奥…

吴江中专计算机网络技术分数线,2018中考分数线|吴江、昆山、太仓中考录取分数线出炉!截止到目前这些学校分数线已公布!...

原标题&#xff1a;2018中考分数线|吴江、昆山、太仓中考录取分数线出炉&#xff01;截止到目前这些学校分数线已公布&#xff01; 这两天&#xff0c;中考BBMM们可算忙坏了&#xff0c; 等分数线的日子比查分还要煎熬&#xff0c; 截止到目前&#xff0c; 苏外、昆山、太仓等学…

哈罗小贝异军突起 苏州太仓“文艺复兴”

苏南太仓自古为文化之乡&#xff0c;南北文化交融、江海文明相汇&#xff0c;形成了独特风格的娄东文化。吴国在这里屯粮建仓&#xff0c;元朝于此地开创“漕运文化”&#xff1b;文学先驱王世贞独主文坛20年为今天留下悠久而优秀的文化财富。今天&#xff0c;在移动阅读和新媒…