Fureasei

Log Muncher

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