Advertisement
DreamChasersMUSH

DCMUSH Log Muncher

Oct 18th, 2019 (edited)
1,140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.59 KB | None | 0 0
  1. # coding: utf-8
  2.  
  3. #
  4. # "I'm Metal Digger Locus, and this is my favorite log-editing script!" -Metal Digger Locus
  5. #
  6. #______ ______ ___ ______
  7. #___ / _____________ _ ___ |/ /___ _________________ /______________
  8. #__ / _ __ \_ __ `/ __ /|_/ /_ / / /_ __ \ ___/_ __ \ _ \_ ___/
  9. #_ /___/ /_/ / /_/ / _ / / / / /_/ /_ / / / /__ _ / / / __/ /
  10. #/_____/\____/_\__, / /_/ /_/ \__,_/ /_/ /_/\___/ /_/ /_/\___//_/ 1.4.3
  11. # /____/
  12.  
  13. # LOG MUNCHER is a script meant to automate 90% of MUSH log editing.
  14. # LOG MUNCHER is hungry for text but will leave it alone if it looks like it might be a pose, radio or a log-worthy comsys message.
  15. # LOG MUNCHER will also take care of minor tasks for you, like format italics and organize your participants list!
  16. # LOG MUNCHER is currently compatible with logs from Dream Chasers, Mega Man MUSH and Battle Fantasia; it is in alpha for SRTMOO
  17. # DCMUSH UPDATE VERSION - Edited by DCMUSH staff (permission to configure graciously given by the code's original creator, Rosaline@DC) and Fureasei!
  18.  
  19. ####### INSTRUCTION MANUAL #######
  20.  
  21. # -Make sure you have pot_spoof on! If you don't, or if you're not sure, you can turn it on by entering these commands:
  22. # For DC: &pot_spoof me=1
  23. # For M3: &config`setting`pot_spoof me=1
  24. # Unfortunately, logs taken before you turned this setting on can't be parsed by Log Muncher. :(
  25. # -Have Python on your computer! (https://www.python.org/downloads/) I did this in 3.7.2 though earlier versions may still work.
  26. # -Copy-paste ALL of this text into a Python script file (You can call it whatever, so long as it has the ".py" extension)
  27. # -Put the script file in some folder
  28. # -Create a folder named "Raw Logs" and a folder named "Edited Logs" in the same directory as the script file
  29. # -Put the logs you want to clean into the Raw Logs folder
  30. # -Look down at the "Options Menu" section just below, and make sure everything is to your liking!
  31. # -~* BE SURE TO SET THE CORRECT MUSH VARIABLE, JUST BELOW *~
  32. # -Run the script and LET THE MAGIC HAPPEN
  33. # -Hopefully nothing explodes! Tell me if it does.
  34.  
  35.  
  36. ####### THE OPTIONS MENU #######
  37. # SAILOR CERI SAYS: Please do NOT remove this part! The script won't run if you do!
  38.  
  39. mush = "DC" # Which game are these logs for? DC = Dream Chasers MUSH, M3 = Mega Man MUSH, BF = Battle Fantasia MUSH, SRTMOO = Super Robot Taisen MOO
  40. displaydesc = 1 # Will display the room desc at the beginning of your log. Set to 0 to turn off. Might miss some formats.
  41. replaceitalics = 1 # Replaces slashes with double apostrophes (the wiki code for italics!)
  42. stopwikiweirdness = 1 # Replaces some characters (<, >, * and ~) with things the wiki isn't allergic to.
  43. maxlength = 120 # The maximum length, in characters, for comsys/radio messages before they wrap around
  44. blurayediting = 1 # Will include in the log lines containing words in the customizable list below, to help editing.
  45. bluraylist = ["bluray", "blu-ray", "blue-ray", "blue ray", "fix it in post"] # Feel free to add your own!
  46. bluraywarning = 1 # If set to 1, will put a BIG NOTE at the beginning of the log telling you to check for bluray edits.
  47. #minushours = ???
  48.  
  49. # SAILOR CERI REITERATES: Please do NOT remove this part! The script won't run if you do!
  50.  
  51.  
  52. import re
  53. import os
  54. import textwrap
  55. import sys
  56. import time
  57.  
  58. logsedited = 0
  59. logsleftalone = 0
  60.  
  61. logging = 0
  62. isthisapose = 0 #0 = not a pose, 1 = pose body, 2 = nospoof header
  63. sortoflogging = 0
  64. startpose = 0
  65. nospoof = re.compile(r"(?<=^<Pose Tracker>)(.*)(?= has posed\.$)")
  66. SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
  67. os.chdir(SCRIPT_DIR)
  68. print("Hi. My current folder is ",os.getcwd())
  69. nospoof = re.compile(r"(?<=^<Pose Tracker>)(.*)(?= has posed\.$)")
  70.  
  71. if mush == "DC":
  72. whitelist = ["=< CHALLENGE -", "<* CHALLENGE -", " |Dungeon Ability: ", "-< Challenge", "= Dungeon Conditions:", "| QUICK TIME EVENT!!!|",
  73. "=< Results -", "<* Results -", "< Party >"]
  74. comsysprefixes = ["GS: ", "DG: ", "DC: ", "QTE!!! Challenge Result:"]
  75. radiolist = []
  76. banlist = ["+=======", "========", "--------", "..................", "===== +health", "===== +scenesys", "===== +stats:" \
  77. "This world is Pueblo ", "Logging to file ", "Logging Started: ", \
  78. "[OOC] ", "[BBS] ", "[JOBS] ", "[WATCH] ", "[GRID] ", "[FLIP] ", "[HELP] ", "MAIL: ", "[FCLIST] ", "[FINGER] ", \
  79. "(New BB Message (", "<GROUP BB> ", "+vote: ", "+Vote: ", "+votes: ", " +pot/soundtrack:", \
  80. "<Guest> ", "<Public> ", "<Ask-Staff> ", "<Discussion> ", "<Entertainment> ", "<RP Finder> ", "<Spoilers> ", "<Support> ", \
  81. "<Big Scene> ", "<Characters> ", "<O-", \
  82. "You will no longer hear messages on channel ", "You will now hear messages on channel ", \
  83. "--- Disconnected", "--- Connected", \
  84. "You paged ", "From afar, ", "From afar (to ", "Long distance to ", \
  85. "You start your posting to Board #", "Player Name On For Idle Doing", \
  86. "Huh? (Type ", "I don't see that here.", \
  87. "= +stats", "BSYS:", "= +health", "= +buckets", "= +attacks", "= Libra:", "= Pokemon Box For", "= Specialties for"]
  88. banlist_nonprefix = [" pages: ", " has connected.\n", " has disconnected.\n", " has partially disconnected.\n",
  89. " has reconnected.\n", " heads over from ", " heads over to ", " has left.\n", " has arrived.\n",
  90. " just looked at you.\n", "'s last pose:"]
  91. comsys_narcissism = [" fully healed ", "party information reset", "Exhaustion reset", \
  92. "You've readied your Tool", "You use your Tool", \
  93. "DG: You pass the challenge,", "DG: You fail the challenge,", \
  94. "GS: Freeattacks wiped from your current mode.", " has been added to slot ",
  95. " Please provide a more specific Tool.", "DG: You can't load that many tools!",
  96. "DG: You've unloaded your Tool,", "DG: You've already acted for this turn.",
  97. "DG: You don't have a party leader right now!", "DG: That's not a valid party leader.",
  98. "You must use a Basic Action that matches the Challenge's Dungeon Ability.",
  99. "You have created a party! Your Digger status has been reset!",
  100. "Not everyone in the party has acted yet.",
  101. " has joined your party!",
  102. " has created a party! To join, type +party/reset and then type +party/join "]
  103. elif mush == "M3":
  104. whitelist = ["hey there, I hope you're enjoying LOG MUNCHER! this is a placeholder message"]
  105. comsysprefixes = ["COMBAT:"]
  106. radiolist = ["<Radio: A - ", "<Radio: B - ", "<Radio: C - ", "<Radio: D - ", \
  107. "<Radio: E - ", "<Radio: F - ", "<Radio: G - ", "<Radio: H - ", \
  108. "<Radio> You intercept a transmission to ", \
  109. "<Live> ", "<Radio> Tightbeam "] #Add the rest of the alphabet soup yourself if you play an interceptor!
  110. banlist = ["_______", "========", "--------", \
  111. "This world is Pueblo ", "Logging to file ", "Logging Started: ", \
  112. "[OOC] ", "MAIL: ", "SAVE: ", "WF: ", "GAME: ", "CHAT: ", \
  113. "(New BB Message", "(New BB message ", "+vote: ", \
  114. "<Guests> ", "<Public> ", "<Discussions> ", "<Q-Spoilers> ", "<Fandom> ", \
  115. "<O-", "<Munchkinery> ", "<NC-X-17+> ", "<RP!> ", "<Hard Nerd> ", "<Altchars>", \
  116. "<B-Music> ", "<ElseMUSH> ", "<Staff Hotline> ", "<Tech> ", "<Workouts> ", \
  117. "You will no longer hear messages on channel ", "You will now hear messages on channel ", \
  118. "--- Disconnected", "--- Connected", "There's no place like home...", \
  119. "You paged ", "From afar, ", "From afar (to ", "Long distance to ", \
  120. "You start your posting to Board #", "Player Name On For Idle Doing", \
  121. "Huh? (Type ", "I don't see that here.", "Your description has been changed to ", \
  122. "You have earned ", "P1 WINS.", "You are out of +cookies for the week.", "You hand ", \
  123. "Type their full name to +cookie someone.", \
  124. "You don't have the Buster ability."]
  125. banlist_nonprefix = [" pages: ", " has connected.\n", "has disconnected.\n", " has partially disconnected.\n",
  126. " has reconnected.\n", " heads over from ", " heads over to ", " has left.\n", " has arrived.\n",
  127. " just looked at you."
  128. " flips a coin in the air and it comes down ", " has been set as your armor ",
  129. " hands you a cookie for a job well done!"]
  130. comsys_narcissism = [" has reset their systems to full.", " has been added to slot ",
  131. " has been added to your queue.",
  132. "You take more damage due to your system weaknesses.",
  133. "You take less damage due to your system weaknesses.",
  134. " points of damage taken!", " life energy left!", "COMBAT: Your attack has been added to ",
  135. "You have set yourself to be automatically grabby-handed by a weapon copy user.",
  136. "You do not appear to have an armor in the a slot.",
  137. " weapon energy available!", " weapon energy to you.", " You have healed ",
  138. " to your current status effects.", " You do not have any general attacks setup yet.",
  139. " has been set on your ", "Data doesn't like it when people try to skip in line at the buffet."]
  140. elif mush == "BF":
  141. whitelist = ["hey there, I hope you're enjoying LOG MUNCHER! this is a placeholder message"]
  142. comsysprefixes = ["COMBAT: ", "BEAMWAR: ", "OOC: ", "DICE: ", "COIN FLIP: ",]
  143. radiolist = ["<I-"]
  144. banlist = ["*+*+*+*+*+", ".********", "|********", ".*+*+*+*+*", "'***********", "==========", "-------------", \
  145. "This world is Pueblo ", "Logging to file ", "Logging Started: ", \
  146. "[OOC] ", "+help", "ALERT: ", "MAIL: ", "+watchfor: ", "GAME: ", \
  147. "There are no unread postings on the Global Bulletin Board.", "Your bbpost has been discarded.",
  148. "Text added to bbpost.", "+vote: ", "+sparkle: ", "+finger: ", "+queue: ", "+soundtrack: ", "+freeattack/set: ", \
  149. "+freeattack/wipe: ", "+heal/boss: ", \
  150. "<Guests> ", "<Public> ", "<Ask-Staff> ", "<Discussion> ", "<Entertainment> ", "<LFRP> ", \
  151. "<Spoilers> ", "<Cooking>", "<Characters>", "<Fitness>", "<O-DF>", "<O-Infinity>", "<O-Ends>", "<O-MA>", \
  152. "<O-Tuners>", "<O-Juuban>", "<O-Ohtori>", \
  153. "You will no longer hear messages on channel ", "You will now hear messages on channel ", "Logging to file", \
  154. "You can't do that.", "--- Connected", \
  155. "You paged ", "From afar, ", "From afar (to ", "Long distance to ", \
  156. "You start your posting to Board #", "Player Name On For Idle", \
  157. "Huh? (Type ", "I don't see that here.", \
  158. "ALERT: You are now able"]
  159. banlist_nonprefix = [" has cancelled their", " could match more than one player."," doesn't have an incoming attack",
  160. "has not concluded their actions. Reactions are not yet available.\n", " pages: ", " has connected.\n",
  161. "has disconnected.\n", " has partially disconnected.\n", " just looked at you.",
  162. " has reconnected.\n", " heads over from ", " heads over to ", " has left.\n", " has arrived.\n",]
  163. comsys_narcissism = [" fully healed ", " has gone to Tokyo with +tokyo.", "COMBAT: Your next attack will not",
  164. "COMBAT: Player not found.", "COMBAT: You can only attack people in the same room as you.",
  165. "COMBAT: You can't", "COMBAT: No one by that name", "COMBAT: Your combo will",
  166. "COMBAT: You haven't started a combo", "COMBAT: You can only", "COMBAT: Player not found.",
  167. "COMBAT: You've found a bug.", "COMBAT: You must use",
  168. "COMBAT: You are already in a BEAMWAR, and may only be in one at a time.",
  169. "COMBAT: Without the barrier flag, only a ",
  170. "COMBAT: The entered attack name could match more than one available attack.",
  171. "COMBAT: Unrecognized attack. Please check for typos in the attack name entered.",
  172. "COMBAT: You cannot use an attack with a TEAM flag with +counter. Please see +help +combo.",
  173. "COMBAT: You cannot use an attack with the Item Grab flag with +counter. Please see +help Items.",
  174. "COMBAT: You don't have",
  175. "COMBAT: Your next attack will not KO your opponent(s) (unless +accept is used).",
  176. "COMBAT: Please use +accept ", "COMBAT: You cannot ", "COMBAT: You don't have",
  177. " has finished attacking."]
  178. elif mush == "SRTMOO":
  179. whitelist = ["< FLASHPOINT CHALLENGE: ", "< TITLE: ", "< DIFFICULTY: ", "< TENSION: ", "< Round "]
  180. comsysprefixes = ["KTS: ", "FPS: ", "FPT: "]
  181. radiolist = ["[P-", "[T-", "[VERTEX] "]
  182. banlist = ["=---------", "==============================", "+-----", "=-------------[", "/--------------", "\\--------------", \
  183. "This world is Pueblo ", "Logging to file ", "Logging Started: ", \
  184. "[OOC] ", "[Public] ", "[Guest] ", "[Ask Staff] ", "[Spoilers] ", "[RP-Seeking] ", "[Entertainment] ", "[Support] ", \
  185. "[Big-Scene] ", "[Characters] ", "[Leadership] ", "[Debug] ", "[Coordination] ", "[O-", "From afar, ","You paged ", \
  186. "Long distance to ", "BBSYS: ", "SCENESYS: ", "CHANSYS: ", "You are empty-handed.", "I don't understand that.", \
  187. "You are now gagging ", "You are no longer gagging ", "Now gagging all channels.", "All channels ungagged.", \
  188. "Player name Connected Idle time Location", "You have new mail ", \
  189. "Type `help mail' for info on reading it."]
  190. banlist_nonprefix = [" has disconnected.\n", " has partially disconnected.\n", " has reconnected.\n", " has connected.\n",
  191. " have disconnected.\n", " have partially disconnected.\n", " have reconnected.\n", " have connected.\n",
  192. " just looked at you.", " heads over from ", " heads over to ", " has left.\n", " has paged you with,",
  193. ") has paged ", " teleports in.\n", " teleports out.\n", " is now set observer.\n"]
  194. comsys_narcissism = ["KTS: Weapon: ", "KTS: EN Regen activates. ", "KTS: SP Regen activates. ", "KTS: Your unit's HP stands at ",
  195. "KTS: Your EN is now ", "KTS: You're out of the fight.", " has changed loadout.", " has completed their actions for the round.",
  196. " has placed a bucket with capacity ", " has cleared their bucket.", "'s bucket!\n", " has left\n",
  197. " has created party for Flashpoint #", "FPT: The party led by ", "FPT: Round Complete!",
  198. "FPT: +flash/draw to start a new round!", "FPT: Drawing Card ", "'s party!\n",
  199. "Physical,Melee", "Physical,Ranged", "Beam,Melee", "Beam,Ranged", "Force,Melee", "Force,Ranged",
  200. "Magic,Melee", "Magic,Ranged", "Melee,Passive", "Ranged,Passive"]
  201.  
  202. if blurayediting == 1:
  203. whitelist.extend(bluraylist)
  204.  
  205. log = []
  206. cast = []
  207. logdate = ""
  208. location = ""
  209. roomdesc = []
  210.  
  211.  
  212. if mush == "DC":
  213. usualheader = "====<* "
  214. locationban = "==<* Inn of the Last Home *>=="
  215. quietroom = "==<* Big Bridge *>=="
  216. roomevidence = "------< Players >------"
  217. elif mush == "M3":
  218. usualheader = "======="
  219. locationban = "OOC Lounge"
  220. quietroom = "Quiet Room"
  221. roomevidence = "--- Contents ---"
  222. elif mush == "BF":
  223. usualheader = "+*+*+*+ "
  224. locationban = "OOC Lounge - The Great Cake"
  225. quietroom = "Quiet Room - Parfait of Silence"
  226. roomevidence = "+*+*+* Players +*+*+*"
  227. elif mush == "SRTMOO":
  228. usualheader = "--------< "
  229. locationban = "Inexplicable Vending Machine Corner"
  230. quietroom = "Medbay"
  231. roomevidence = "------< Players >------"
  232.  
  233. mightbelocation = ""
  234. mightberoomdesc = []
  235.  
  236. thisisnowaresultsscreen = 0
  237. bluraycount = 0
  238.  
  239. poses = []
  240. previousline = ""
  241. previousroomline = ""
  242.  
  243. print(" ")
  244. print("WELCOME TO...")
  245. print(" ")
  246. print(r"______ ______ ___ ______")
  247. print(r"___ / _____________ _ ___ |/ /___ _________________ /______________")
  248. print(r"__ / _ __ \_ __ `/ __ /|_/ /_ / / /_ __ \ ___/_ __ \ _ \_ ___/")
  249. print(r"_ /___/ /_/ / /_/ / _ / / / / /_/ /_ / / / /__ _ / / / __/ /")
  250. print(r"/_____/\____/_\__, / /_/ /_/ \__,_/ /_/ /_/\___/ /_/ /_/\___//_/")
  251. print(r" /____/")
  252. print(" ")
  253. print(" (!) Don't forget to double-check your munched logs before posting! MUNCHERCORP")
  254. print(" will NOT be held responsible if your embarrassing pages end up on the wiki.")
  255. print(" ")
  256. print("\"I'm Metal Digger Locus, and this is my favorite log-editing script!\"")
  257. print(" - Metal Digger Locus")
  258. print(" ")
  259.  
  260. try:
  261. for log in os.listdir("./Raw Logs/"):
  262.  
  263. if os.path.isfile("./Edited Logs/" + log):
  264. logsleftalone += 1
  265. else:
  266. print("Now editing: " + log)
  267. try:
  268. with open ("./Raw Logs/" + log, 'rt') as in_file:
  269. loglastedited = os.path.getmtime("./Raw Logs/" + log)
  270. logdate = time.strftime("%B %d, %Y", time.gmtime(loglastedited - 54000))
  271.  
  272. for line in in_file:
  273. for banitem in banlist:
  274. if line.startswith(banitem):
  275. if (thisisnowaresultsscreen == 1):
  276. break
  277. if usualheader in line and locationban not in line and quietroom not in line:
  278. mightbelocation = line
  279. sortoflogging = 1
  280. elif sortoflogging == 1 and roomevidence in line:
  281. location = mightbelocation
  282. roomdesc = mightberoomdesc
  283. sortoflogging = 0
  284. mightberoomdesc = []
  285. else:
  286. sortoflogging = 0
  287. mightberoomdesc = []
  288. logging = 0
  289. if isthisapose == 1 and mush == "DC":
  290. poses.append("</poem>\n")
  291. elif isthisapose == 1 and mush == "SRTMOO":
  292. poses.append("</poem>\n")
  293. isthisapose = 0
  294. break
  295. for ughitem in banlist_nonprefix:
  296. if ughitem in line:
  297. if isthisapose == 1 and mush == "DC":
  298. poses.append("</poem>\n")
  299. elif isthisapose == 1 and mush == "SRTMOO":
  300. poses.append("</poem>\n")
  301. logging = 0
  302. isthisapose = 0
  303. sortoflogging = 0
  304. mightberoomdesc = []
  305. break
  306. if nospoof.search(line):
  307. if mush == "DC":
  308. if not "[[Character :: " + line[15:-12] + "]]" in cast:
  309. cast.append("[[Character :: " + line[15:-12] + "]]")
  310. elif mush == "M3":
  311. if "]" in line:
  312. if not line[15:-16] in cast:
  313. cast.append(line[15:-16])
  314. else:
  315. if not line[15:-12] in cast:
  316. cast.append(line[15:-12])
  317. elif mush == "BF":
  318. if not "[[" + line[15:line.find(" [") - len(line)] + "]]" in cast:
  319. cast.append("[[" + line[15:line.find(" [") - len(line)] + "]]")
  320. elif mush == "SRTMOO":
  321. if not "[[Character :: " + line[15:-12] + "]]" in cast:
  322. cast.append("[[Character :: " + line[15:-12] + "]]")
  323. logging = 1
  324. startpose = 1
  325. for whiteitem in whitelist:
  326. if whiteitem in line:
  327. if isthisapose == 1 and mush == "DC":
  328. poses.append("</poem>\n")
  329. elif isthisapose == 1 and mush == "SRTMOO":
  330. poses.append("</poem>\n")
  331. isthisapose = 0
  332. logging = 1
  333. sortoflogging = 0
  334. mightberoomdesc = []
  335. if blurayediting == 1:
  336. for blueitem in bluraylist:
  337. if blueitem in line:
  338. bluraycount += 1
  339. for prefix in comsysprefixes:
  340. if line.startswith(prefix):
  341. if isthisapose == 1 and mush == "DC":
  342. poses.append("</poem>\n")
  343. elif isthisapose == 1 and mush == "SRTMOO":
  344. poses.append("</poem>\n")
  345. isthisapose = 0
  346. logging = 1
  347. sortoflogging = 0
  348. mightberoomdesc = []
  349. for myitem in comsys_narcissism:
  350. if myitem in line:
  351. logging = 0
  352. break
  353. for radiotype in radiolist:
  354. if line.startswith(radiotype):
  355. if isthisapose == 1 and mush == "DC":
  356. poses.append("</poem>\n")
  357. elif isthisapose == 1 and mush == "SRTMOO":
  358. poses.append("</poem>\n")
  359. isthisapose = 0
  360. logging = 1
  361. sortoflogging = 0
  362. mightberoomdesc = []
  363.  
  364. if logging == 1:
  365. if ("<* CHALLENGE -" in line or "< FLASHPOINT CHALLENGE: " in line):
  366. if not previousline.isspace():
  367. poses.append("\n")
  368. poses.append(" " + previousroomline)
  369. elif ("< Results -" in line):
  370. if not previousline.isspace():
  371. poses.append("\n")
  372. poses.append(" " + previousroomline)
  373. thisisnowaresultsscreen = 1
  374. elif ("= Digger 2.0 =" in line):
  375. thisisnowaresultsscreen = 0
  376. elif (nospoof.search(line) != None):
  377. if isthisapose == 1 and mush == "DC":
  378. poses.append("</poem>\n")
  379. elif isthisapose == 1 and mush == "SRTMOO":
  380. poses.append("</poem>\n")
  381. isthisapose = 2
  382. else:
  383. for prefix in comsysprefixes:
  384. if line.startswith(prefix):
  385. if not previousline.startswith(prefix) and not previousline.isspace():
  386. if isthisapose == 1 and mush == "DC":
  387. poses.append("</poem>\n")
  388. elif isthisapose == 1 and mush == "SRTMOO":
  389. poses.append("</poem>\n")
  390. poses.append("\n")
  391. isthisapose = 0
  392. for radiotype in radiolist:
  393. if line.startswith(radiotype):
  394. if not previousline.startswith(radiotype) and not previousline.isspace():
  395. if isthisapose == 1 and mush == "DC":
  396. poses.append("</poem>\n")
  397. elif isthisapose == 1 and mush == "SRTMOO":
  398. poses.append("</poem>\n")
  399. poses.append("\n")
  400. isthisapose = 0
  401. if isthisapose == 0:
  402. if len(line) > maxlength:
  403. for subline in textwrap.wrap(line, maxlength):
  404. poses.append(" " + subline + "\n")
  405. else:
  406. poses.append(" " + line)
  407. elif isthisapose == 2:
  408. if not previousline.isspace():
  409. poses.append("\n")
  410. if mush == "M3":
  411. poses.append("\n")
  412. poses.append(" " + line)
  413. isthisapose = 1
  414. elif isthisapose == 1:
  415. if line.startswith("<SoundTracker> "):
  416. line = " " + line
  417. poses.append(line)
  418. else:
  419. if replaceitalics == 1 and line.count("/"):
  420. if not (line.count("/") % 2):
  421. line = line.replace("/", "''")
  422. if stopwikiweirdness == 1:
  423. line = line.replace("*", "&#42;")
  424. line = line.replace("<", "&lt;")
  425. line = line.replace(">", "&gt;")
  426. line = line.replace("\t", " ")
  427. line = line.replace("~~~", "<nowiki>~~~</nowiki>")
  428.  
  429. if startpose == 1:
  430. if mush == "DC":
  431. poses.append("<poem>" + line)
  432. elif mush == "SRTMOO":
  433. poses.append("<poem>" + line)
  434. startpose = 0
  435. else:
  436. poses.append(line)
  437. previousline = line
  438. if sortoflogging == 1:
  439. if line != previousroomline:
  440. mightberoomdesc.append(line)
  441. previousroomline = line
  442.  
  443. try:
  444. with open ("./Edited Logs/" + log, 'wt') as out_file:
  445. if bluraywarning and bluraycount:
  446. out_file.write("\n<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
  447. if bluraycount == 1:
  448. out_file.write("Check your log for bluray editing! " + str(bluraycount) + " mark was detected!\n")
  449. else:
  450. out_file.write("Check your log for bluray editing! " + str(bluraycount) + " marks were detected!\n")
  451. out_file.write("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->\n\n")
  452. if mush == "DC":
  453. out_file.write("*'''Log: " + log[:-4] + "'''\n" + \
  454. "*'''Cast:''' ")
  455. out_file.write(', '.join(cast))
  456. out_file.write("\n*'''Where:''' " + location.rstrip(" *>=\n").lstrip("=<* ") + "\n" + \
  457. "*'''Date:''' " + logdate + "\n" + \
  458. "*'''Summary''': ''<Summarize!>''\n\n" + \
  459. "----\n")
  460. if displaydesc == 1:
  461. out_file.write("\n")
  462. for liney in roomdesc:
  463. out_file.write(" " + liney)
  464. if liney.startswith("BGM: "):
  465. break
  466. elif mush == "M3":
  467. out_file.write("{{Infobox Log\n" + \
  468. "|title=" + log[:-4] + "\n" + \
  469. "|recap=\n" + \
  470. "|rldate=" + logdate + "\n" \
  471. "|icdate=YYYY-MM-DD\n" + \
  472. "|storyarc=\n" + \
  473. "|scenetype=\n" + \
  474. "|participants=")
  475. out_file.write(', '.join(cast))
  476. out_file.write("\n|location=" + location.rstrip(" =\n").lstrip("= ") + "\n}}\n\n")
  477.  
  478. if displaydesc == 1:
  479. out_file.write("\n")
  480. for liney in roomdesc:
  481. out_file.write(" " + liney)
  482. elif mush == "BF":
  483. out_file.write('{|class="toccolours" cellspacing="2"\n' + \
  484. "|-\n" + \
  485. '! style="background:#CC6699; border: 2px #CC0033 solid; font-size: 110%;" align="center" colspan="2" | ' + \
  486. "'''Title: " + log[:-4] + "'''" + "\n" + \
  487. "|-\n" + \
  488. "|'''Summary''':<br>\n" + \
  489. "''<The summary>''\n" + \
  490. "|-\n" + \
  491. "|'''Who''':<br>\n")
  492. out_file.write(', '.join(cast))
  493. out_file.write("\n" + \
  494. "|-\n" + \
  495. "|'''Where:'''<br>\n")
  496. out_file.write(location.rstrip(" +*\n").lstrip("*+ ") + "\n}}\n\n")
  497. out_file.write("|-\n" + \
  498. "|'''OOC - IC Date:'''<br>\n")
  499. if logdate:
  500. out_file.write(logdate + " - <IC Date>\n")
  501. else:
  502. out_file.write("<OOC Date> - <IC Date>\n")
  503. out_file.write("|-\n" + \
  504. "|}\n")
  505. if displaydesc == 1:
  506. out_file.write("\n")
  507. for liney in roomdesc:
  508. out_file.write(" " + liney)
  509. if "*+*+* Players +*+*" in liney:
  510. break
  511. elif mush == "SRTMOO":
  512. out_file.write("*'''Log: " + log[:-4] + "'''\n" + \
  513. "*'''Cast:''' ")
  514. out_file.write(', '.join(cast))
  515. out_file.write("\n*'''Where:''' \n" + \
  516. "*'''OOC - IC Date:''' \n" + \
  517. "*'''Summary''': ''<Summarize!>''\n\n" + \
  518. "----\n")
  519. if displaydesc == 1:
  520. out_file.write("\n")
  521. for liney in roomdesc:
  522. out_file.write(" " + liney)
  523. if liney.startswith("BGM: "):
  524. break
  525.  
  526. for linex in poses:
  527. out_file.write(linex)
  528.  
  529. #Timestamps obtained from https://www.epochconverter.com/
  530. if mush == "DC":
  531. if (loglastedited - 54000) < 1503273600: #End of Chapter 1 Act 1: August 20th, 2017 (or thereabouts)
  532. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 1]]\n[[Category:Chapter 1, Act 1]]")
  533. elif (loglastedited - 54000) < 1520272800: #End of Chapter 1 Act 2: March 4th, 2018
  534. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 1]]\n[[Category:Chapter 1, Act 2]]")
  535. elif (loglastedited - 54000) < 1535907600: #End of Chapter 1 Act 3: September 1st, 2018
  536. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 1]]\n[[Category:Chapter 1, Act 3]]")
  537. elif (loglastedited - 54000) < 1545588000: #End of Chapter 1 Act 4: December 22nd, 2018
  538. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 1]]\n[[Category:Chapter 1, Act 4]]")
  539. elif (loglastedited - 54000) < 1553277600: #End of Chapter 1: March 14th, 2019
  540. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 1]]\n[[Category:Chapter 1, Epilogue]]")
  541. elif (loglastedited - 54000) < 1571082593: #End of Chapter 2 Act 1: October 13th, 2019
  542. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 2]]\n[[Category:Chapter 2, Act 1]]")
  543. elif (loglastedited - 54000) < 1601292630: #End of Chapter 2 Act 2: September 28th, 2020
  544. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 2]]\n[[Category:Chapter 2, Act 2]]")
  545. elif (loglastedited - 54000) < 1627790400: #End of Chapter 2 Act 3: July 31st, 2021
  546. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 2]]\n[[Category:Chapter 2, Act 3]]")
  547. elif (loglastedited - 54000) < 1682253030: #End of Chapter 2 Act 4: April 22nd, 2023
  548. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 2]]\n[[Category:Chapter 2, Act 4]]")
  549. elif (loglastedited - 54000) < 1702817999: #End of Chapter 2: December 17th, 2023
  550. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 2]]\n[[Category:Chapter 2, Epilogue]]")
  551. else:
  552. out_file.write("\n[[Category:Logs]]\n[[Category:Chapter 3]]\n[[Category:Chapter 3, Act 1]]")
  553. elif mush == "M3":
  554. pass
  555. elif mush == "BF":
  556. out_file.write("\n[[Category:Logs]]\n")
  557. elif mush == "SRTMOO":
  558. if (loglastedited - 54000) < 1656288000: #End of Phase 1 Turn 1: August 26th, 2022 (or thereabouts)
  559. out_file.write("\n[[Category:Logs]]\n[[Category:Phase 1]]\n[[Category:Phase 1, Turn 1]]")
  560. elif (loglastedited - 54000) < 1675818000: #End of Phase 1 Turn 2: February 7th, 2023 (or thereabouts)
  561. out_file.write("\n[[Category:Logs]]\n[[Category:Phase 1]]\n[[Category:Phase 1, Turn 2]]")
  562. elif (loglastedited - 54000) < 1704067200: #End of Phase 1 Turn 3: December 31st, 2023
  563. out_file.write("\n[[Category:Logs]]\n[[Category:Phase 1]]\n[[Category:Phase 1, Turn 3]]")
  564. elif (loglastedited - 54000) < 1713744000: #End of Phase 1 Special Disc: April 21st, 2024
  565. out_file.write("\n[[Category:Logs]]\n[[Category:Phase 1]]\n[[Category:Phase 1 Special Disc]]")
  566. else:
  567. out_file.write("\n[[Category:Logs]]\n[[Category:Phase 2]]\n[[Category:Phase 2, Turn 1]]")
  568. if bluraycount:
  569. print(" Bluray marks detected: " + str(bluraycount))
  570.  
  571. logsedited += 1
  572. poses = []
  573. cast = []
  574. logdate = ""
  575. location = ""
  576. roomdesc = []
  577. bluraycount = 0
  578.  
  579. except FileNotFoundError:
  580. print("Can't create write file? Maybe there's no Edited Logs folder.")
  581.  
  582. except FileNotFoundError:
  583. print("File not found. Hm.")
  584.  
  585. except FileNotFoundError:
  586. print("No files found in Raw Logs folder, or no Raw Logs folder found, probably.")
  587.  
  588. print("Logs left alone: " + str(logsleftalone))
  589. print("Logs edited: " + str(logsedited))
  590. print(" ")
  591. input("Thank you for using LOG MUNCHER! Press Enter to exit.")
  592.  
  593.  
  594. ####### F.A.Q. #######
  595.  
  596. # Q. I found a bug! LOG MUNCHER isn't eating something it should probably eat!
  597. # A. Look if it's not in Known Issues first, and if not, contact staff -- we'll see if we can tweak something or contact Rosaline's player about it.
  598. # It would be very helpful if you could supply us with the raw, SPECIFIC text that seems to cause a problem. The appbox or a pastebin link would be best!
  599. #
  600. # Q. I wish friendly, hungry cybersaur LOG MUNCHER had this feature!
  601. # A. @mail or page us and we'll see what we can do! Rosaline's player graciously gave us permission to edit but staff only knows enough Python to get by -- but it could be a good learning opportunity!
  602. #
  603. # Q. I know some code. Can I adapt LOG MUNCHER to do a thing, such as work on a currently unsupported MU*?
  604. # A. Sure! LOG MUNCHER is open source. If you give us your code, we might even use it to improve the official LOG MUNCHER.
  605. # (Just don't mind the mess!)
  606.  
  607.  
  608. ####### KNOWN ISSUES #######
  609.  
  610. # -Pre-scene OOC lounge chatter will be kept in if it involves comsys tomfoolery
  611. # STATUS: Fixable but low-priority, since this comes up rarely and the edit is usually very simple
  612. # -Some messages that will NOT ALWAYS be filtered out, and must be edited out manually:
  613. # -people moving from one room to another
  614. # STATUS: Potentially unfixable :(
  615. # -people's descs
  616. # STATUS: Potentially unfixable :(
  617. # -some clients' connect message if you reconnect mid-scene
  618. # STATUS: This latter one is fixable, but you'll need to tell me what your connect message is!
  619. # -Some messages that will sometimes MISTAKENLY be filtered out, and must be edited back in:
  620. # -Pose paragraphs starting with "From afar" (confused with a page message)
  621. # -Pose paragraphs including the sentence "heads over to" (confused with someone moving to another room)
  622. # STATUS: Trying to figure out a solution to both, whatever it is will likely not be perfect.
  623. # -Digger results readouts that break the buffer cause OOC messages to remain in
  624. # STATUS: The bug is potentially unfixable on my end, and more dependent on the MUSH's side.
  625. # -Editing several logs at once will sometimes fuse them. What the heck!
  626. # STATUS: Can't reproduce. More data needed!
  627. # -The Muncher window won't stay open for some people.
  628. # STATUS: Can't reproduce. More data needed!
  629. #
  630. # --> DO tell me if the script forgets to eat something not covered here/eats the wrong thing.
  631. # If possible, send me the specific message.
  632. #
  633. # Thank you for using LOG MUNCHER!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement