-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenpy_tool.py
34 lines (24 loc) · 1011 Bytes
/
renpy_tool.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import re
import time
import datetime
date_format = '%Y-%m-%d %H:%M:%S'
def running_log(log: str):
date = datetime.datetime.fromtimestamp(time.time()).strftime(date_format)
print(f"[{date}]: {log}")
def remove_origin_lore(seq: str):
while seq.endswith("原文{/lore}{/size}"):
lore_start = seq.rfind("{size=*0.5}{lore=")
seq = seq[:lore_start]
return seq
def remove_flag(input_: str):
# 为原文lore准备
input_ = remove_origin_lore(input_)
input_ = input_.replace('{i}', '').replace('{/i}', '')
input_ = input_.replace('{b}', '').replace('{/b}', '')
input_ = input_.replace('{s}', '').replace('{/s}', '')
input_ = input_.replace('[', '').replace(']', '')
input_ = re.sub(r'{size=[-+]?\d+}', '', input_).replace('{/size}', '')
input_ = re.sub(r'{lore=.*?}', '', input_).replace('{/lore}', '')
input_.replace('{rb}', '').replace('{/rb}', '')
input_ = re.sub(r'{rt}.*?{/rt}', '', input_).replace('{/lore}', '')
return input_