Difference between revisions of "User:Victor Bearwolf/temp"
From Game Logs
m |
|||
Line 1: | Line 1: | ||
− | < | + | <noinclude> |
+ | Discord to ur-dnd logs converter currently set up for [[On that September]].<br/> | ||
+ | Just save it as "SEP_logfixer.wsf" and then run in Windows(r). Before that export Discord logs as text by DiscordCharExporter to "SEP_new.txt".<br/> | ||
+ | To configure for other games just rename players and characters. And filenames.<br/> | ||
+ | <pre> | ||
+ | <job id="LogFixer"> | ||
+ | <script name="JScript"> | ||
+ | |||
+ | var strInputFile = "SEP_new.txt"; | ||
+ | var strOutputFile = "SEP.txt"; | ||
+ | |||
+ | // Read input file into memory | ||
+ | arrLine = new Array(); | ||
+ | fs = new ActiveXObject("Scripting.FileSystemObject"); | ||
+ | fileLog = fs.GetFile(strInputFile); | ||
+ | streamLog = fileLog.OpenAsTextStream(1, 0); | ||
+ | var intCount = 0; | ||
+ | while(!streamLog.AtEndOfStream) { | ||
+ | arrLine[intCount] = streamLog.ReadLine(); | ||
+ | intCount++; | ||
+ | } | ||
+ | streamLog.Close(); | ||
+ | |||
+ | // Prepare output file | ||
+ | fs.CreateTextFile(strOutputFile); | ||
+ | fileNew = fs.GetFile(strOutputFile); | ||
+ | fileNew = fileNew.OpenAsTextStream(8, 0); | ||
+ | fileNew.write("[[Category:On That September]]\r\n"); | ||
+ | |||
+ | // Prepare Find-n-Replace data (TODO: more regexps?) | ||
+ | var arrIn = new Array("Petrovna#3347", "DiceParser#0764", "Victor Bearwolf#2285", "@Victor Bearwolf", "Heckfy[Ex]#1253", "@Heckfy[Ex]", "Bert#5362", "@Bert", "Zuzuzu#6001", "@Zuzuzu", "zigan#8073", "@zigan", " ,", "# ", "\\*", "*", "_", "* -", "```Markdown", "```"); | ||
+ | var arrOut = new Array("<b>GM</b>:", "<b>bot</b>:", "<b>Джек</b>:", "<b>Джек</b>", "<b>Сэм</b>:", "<b>Сэм</b>", "<b>Джеймс</b>:", "<b>Джеймс</b>", "<b>Ринго</b>:", "<b>Ринго</b>", "<b>Фрэнк</b>:", "<b>Фрэнк</b>", ",", "", "\'\'", "\'\'", "\'\'", "\'\' -", "@", "@"); | ||
+ | |||
+ | // Check arrays just in case | ||
+ | if(arrIn.length != arrOut.length) { | ||
+ | WScript.Echo("ERROR! Input and output array lengths do not match."); | ||
+ | WScript.Quit(); | ||
+ | } | ||
+ | |||
+ | var intIndex = arrIn.length; | ||
+ | var strLog = arrLine[0]; | ||
+ | var boolEm = false; | ||
+ | var intMatch = -1; | ||
+ | |||
+ | // Process log data | ||
+ | for(j = 0; j<arrLine.length; j++) { | ||
+ | strLog = arrLine[j] + "\r\n"; | ||
+ | |||
+ | // Remove timestamp | ||
+ | strLog = strLog.replace(/(\[\d{2}-[A-Z][a-z][a-z]-\d{2} \d{2}:\d{2} [AP]M\] )/, ''); | ||
+ | |||
+ | // Escape OOC | ||
+ | strLog = strLog.replace(/(^[\*][ ])/, '* '); | ||
+ | |||
+ | // Clear bot output | ||
+ | //strLog = strLog.replace(/(^[`]*(Markdown)?)/, ''); | ||
+ | |||
+ | // Rename players as characters | ||
+ | for(i = 0; i<intIndex; i++) { | ||
+ | intMatch = strLog.indexOf(arrIn[i]); | ||
+ | while(intMatch != -1) { | ||
+ | var strLog = strLog.replace(arrIn[i], arrOut[i]); | ||
+ | intMatch = strLog.indexOf(arrIn[i]); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // Write result | ||
+ | if(strLog != "@\r\n") { | ||
+ | fileNew.write(strLog); | ||
+ | } | ||
+ | } | ||
+ | fileNew.Close(); | ||
+ | WScript.Echo("Done! Processed "+arrLine.length+" lines\r\nfrom "+strInputFile+" to "+strOutputFile); | ||
+ | |||
+ | </script> | ||
+ | </job> | ||
+ | </pre> | ||
+ | </noinclude><includeonly> | ||
<div style=" | <div style=" | ||
position: fixed; | position: fixed; | ||
Line 43: | Line 120: | ||
margin-top: 100px; | margin-top: 100px; | ||
">𝕻𝖊𝖙𝖎𝖙𝖚𝖒 𝖗𝖊𝖘𝖔𝖚𝖗𝖈𝖊 𝖔𝖇𝖘𝖙𝖗𝖚𝖈𝖙𝖚𝖘 𝖗𝖔𝖌𝖆𝖙𝖚 𝕴𝖓𝖖𝖚𝖎𝖘𝖎𝖙𝖎𝖔𝖓𝖎𝖘.<br>𝕮𝖔𝖓𝖙𝖆𝖈𝖙 𝕺𝖗𝖉𝖔 𝕹𝖚𝖓𝖙𝖎𝖚𝖘 𝖕𝖗𝖔 𝖒𝖆𝖌𝖎𝖘 𝖓𝖔𝖙𝖎𝖙𝖎𝖆.</div> | ">𝕻𝖊𝖙𝖎𝖙𝖚𝖒 𝖗𝖊𝖘𝖔𝖚𝖗𝖈𝖊 𝖔𝖇𝖘𝖙𝖗𝖚𝖈𝖙𝖚𝖘 𝖗𝖔𝖌𝖆𝖙𝖚 𝕴𝖓𝖖𝖚𝖎𝖘𝖎𝖙𝖎𝖔𝖓𝖎𝖘.<br>𝕮𝖔𝖓𝖙𝖆𝖈𝖙 𝕺𝖗𝖉𝖔 𝕹𝖚𝖓𝖙𝖎𝖚𝖘 𝖕𝖗𝖔 𝖒𝖆𝖌𝖎𝖘 𝖓𝖔𝖙𝖎𝖙𝖎𝖆.</div> | ||
− | </div></div | + | </div></div></includeonly> |
Revision as of 22:39, 16 November 2020
Discord to ur-dnd logs converter currently set up for On that September.
Just save it as "SEP_logfixer.wsf" and then run in Windows(r). Before that export Discord logs as text by DiscordCharExporter to "SEP_new.txt".
To configure for other games just rename players and characters. And filenames.
<job id="LogFixer"> <script name="JScript"> var strInputFile = "SEP_new.txt"; var strOutputFile = "SEP.txt"; // Read input file into memory arrLine = new Array(); fs = new ActiveXObject("Scripting.FileSystemObject"); fileLog = fs.GetFile(strInputFile); streamLog = fileLog.OpenAsTextStream(1, 0); var intCount = 0; while(!streamLog.AtEndOfStream) { arrLine[intCount] = streamLog.ReadLine(); intCount++; } streamLog.Close(); // Prepare output file fs.CreateTextFile(strOutputFile); fileNew = fs.GetFile(strOutputFile); fileNew = fileNew.OpenAsTextStream(8, 0); fileNew.write("[[Category:On That September]]\r\n"); // Prepare Find-n-Replace data (TODO: more regexps?) var arrIn = new Array("Petrovna#3347", "DiceParser#0764", "Victor Bearwolf#2285", "@Victor Bearwolf", "Heckfy[Ex]#1253", "@Heckfy[Ex]", "Bert#5362", "@Bert", "Zuzuzu#6001", "@Zuzuzu", "zigan#8073", "@zigan", " ,", "# ", "\\*", "*", "_", "* -", "```Markdown", "```"); var arrOut = new Array("<b>GM</b>:", "<b>bot</b>:", "<b>Джек</b>:", "<b>Джек</b>", "<b>Сэм</b>:", "<b>Сэм</b>", "<b>Джеймс</b>:", "<b>Джеймс</b>", "<b>Ринго</b>:", "<b>Ринго</b>", "<b>Фрэнк</b>:", "<b>Фрэнк</b>", ",", "", "\'\'", "\'\'", "\'\'", "\'\' -", "@", "@"); // Check arrays just in case if(arrIn.length != arrOut.length) { WScript.Echo("ERROR! Input and output array lengths do not match."); WScript.Quit(); } var intIndex = arrIn.length; var strLog = arrLine[0]; var boolEm = false; var intMatch = -1; // Process log data for(j = 0; j<arrLine.length; j++) { strLog = arrLine[j] + "\r\n"; // Remove timestamp strLog = strLog.replace(/(\[\d{2}-[A-Z][a-z][a-z]-\d{2} \d{2}:\d{2} [AP]M\] )/, ''); // Escape OOC strLog = strLog.replace(/(^[\*][ ])/, '* '); // Clear bot output //strLog = strLog.replace(/(^[`]*(Markdown)?)/, ''); // Rename players as characters for(i = 0; i<intIndex; i++) { intMatch = strLog.indexOf(arrIn[i]); while(intMatch != -1) { var strLog = strLog.replace(arrIn[i], arrOut[i]); intMatch = strLog.indexOf(arrIn[i]); } } // Write result if(strLog != "@\r\n") { fileNew.write(strLog); } } fileNew.Close(); WScript.Echo("Done! Processed "+arrLine.length+" lines\r\nfrom "+strInputFile+" to "+strOutputFile); </script> </job>