本站点内容仅供爱好者学习研究参考,不得作为商业用途果园IP网址: 45.79.87.129 IRC: 47.104.23.230 (GB-6667/6668/6669)查看你的订阅:点击这里 查看最新帖子:点击这里最新开团寻团:招聘广场 最新跑团工具:使用指南需要注意事項:果園風紀 便捷路标指示:果园导航
想问一下discord里跑dnd的话,用什么骰娘比较好用呢
引述: \星尘/ 于 2023-11-24, 周五 10:42:19想问一下discord里跑dnd的话,用什么骰娘比较好用呢一般都是用Avrae,可支持D&D Beyond角色卡导入,也可以直接使用官方资源里的数据
那么如何导出log呢?也就是果园的染色版本
import jsonimport osimport redef parse(a): a = re.sub('\*\*(.*?)\*\*', '[b]\\1[/b]', a) a = re.sub('\*(.*?)\*', '[i]\\1[/i]', a) a = re.sub('\|\|(.*?)\|\|', '[color=white]\\1[/color]', a) a = re.sub('`(.*?)`', '[tt]\\1[/tt]', a) a = re.sub('~(.*?)~', '[s]\\1[/s]', a) return adef coloring(entry, c): name_list = ["旁白", "诺瓦莉安", "米克", "伊甘", "巴伦德"] color_list = ["black", "royalblue", "crimson", "seagreen", "#993399"] sentence_list = [] for x in entry.split("\n"): sentence_list.append("[color=" + color_list[c] + "]<" + name_list[c] + "> " + parse(x) + "[/color]") return sentence_listdef auto_format(dict): outputs = [] messages = dict["messages"] for utterance in messages: if int(utterance["author"]["id"]) == 替换为ID数字: #dm colored = coloring(utterance["content"], 0) for sentence in colored: outputs.append(sentence) if int(utterance["author"]["id"]) == 替换为ID数字: #nuowalian colored = coloring(utterance["content"], 1) for sentence in colored: outputs.append(sentence) if int(utterance["author"]["id"]) == 替换为ID数字: #mike colored = coloring(utterance["content"], 2) for sentence in colored: outputs.append(sentence) if int(utterance["author"]["id"]) == 替换为ID数字: #yigan colored = coloring(utterance["content"], 3) for sentence in colored: outputs.append(sentence) if int(utterance["author"]["id"]) == 替换为ID数字: #balunde colored = coloring(utterance["content"], 4) for sentence in colored: outputs.append(sentence) return outputspath = "E:/ProcessedLog/log/"for file in os.listdir(path): if file.endswith(".json"): f = open(path + file, 'r', encoding="utf8") raw = json.load(f) processed = auto_format(raw) with open(file[:-5] + ".txt", 'w', encoding="utf8") as out_f: for p in processed: out_f.write(p + "\n") f.close()
cd 你放log.py的路径python log.py或python3 log.py(如果你以前安装过Python2)
引述: \星尘/ 于 2023-11-25, 周六 20:11:49那么如何导出log呢?也就是果园的染色版本我们DM以前问过这个问题,可以作为参考简单来说要先使用DiscordChatExporter导出频道聊天记录如果导出txt格式的话可以使用关键词替换,导出csv或者json的话可以用程序来处理上面的帖子里有对应的程序,不过我一开始没发现,所以自己也写了一个版本(用来处理json文件):代码: [选择]import jsonimport osimport redef parse(a): a = re.sub('\*\*(.*?)\*\*', '[b]\\1[/b]', a) a = re.sub('\*(.*?)\*', '[i]\\1[/i]', a) a = re.sub('\|\|(.*?)\|\|', '[color=white]\\1[/color]', a) a = re.sub('`(.*?)`', '[tt]\\1[/tt]', a) a = re.sub('~(.*?)~', '[s]\\1[/s]', a) return adef coloring(entry, c): name_list = ["旁白", "诺瓦莉安", "米克", "伊甘", "巴伦德"] color_list = ["black", "royalblue", "crimson", "seagreen", "#993399"] sentence_list = [] for x in entry.split("\n"): sentence_list.append("[color=" + color_list[c] + "]<" + name_list[c] + "> " + parse(x) + "[/color]") return sentence_listdef auto_format(dict): outputs = [] messages = dict["messages"] for utterance in messages: if int(utterance["author"]["id"]) == 替换为ID数字: #dm colored = coloring(utterance["content"], 0) for sentence in colored: outputs.append(sentence) if int(utterance["author"]["id"]) == 替换为ID数字: #nuowalian colored = coloring(utterance["content"], 1) for sentence in colored: outputs.append(sentence) if int(utterance["author"]["id"]) == 替换为ID数字: #mike colored = coloring(utterance["content"], 2) for sentence in colored: outputs.append(sentence) if int(utterance["author"]["id"]) == 替换为ID数字: #yigan colored = coloring(utterance["content"], 3) for sentence in colored: outputs.append(sentence) if int(utterance["author"]["id"]) == 替换为ID数字: #balunde colored = coloring(utterance["content"], 4) for sentence in colored: outputs.append(sentence) return outputspath = "E:/ProcessedLog/log/"for file in os.listdir(path): if file.endswith(".json"): f = open(path + file, 'r', encoding="utf8") raw = json.load(f) processed = auto_format(raw) with open(file[:-5] + ".txt", 'w', encoding="utf8") as out_f: for p in processed: out_f.write(p + "\n") f.close()考虑到未来可能还有人看到这个帖子,顺便贴上Windows环境下的运行流程:直接使用安装包安装Python安装DiscordChatExporter点击Download → GUI → Stable release下载DiscordChatExporter.zip并根据提示安装导出对应频道的json文件复制上方代码粘贴到记事本中,保存时选择UTF-8,保存后修改文件后缀为.py粘贴代码时记得修改对应的文件路径、颜色代码、角色名字和用户ID用户ID可以用记事本打开刚才导出的json文件查看,是一串很长的数字,可以根据对应用户名确认打开WindowsPowerShell(开始菜单里输入terminal)输入以下指令代码: [选择]cd 你放log.py的路径python log.py或python3 log.py(如果你以前安装过Python2)上面的代码可以在Windows/macOS/Linux系统下无差别运行,但DiscordChatExporter只有支持Window的GUI