-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathgen_re_emoji.py
187 lines (182 loc) · 11 KB
/
gen_re_emoji.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import re
re_emoji = r'''
🇺🇸,USA?|UMI?,美[国國]|华盛顿|波特兰|达拉斯|俄勒冈|凤凰城|菲尼克斯|费利蒙|弗里蒙特|硅谷|旧金山|拉斯维加斯|洛杉|圣何塞|圣荷西|圣塔?克拉拉|西雅图|芝加哥|哥伦布|纽约|阿什本|纽瓦克|丹佛|加利福尼亚|弗吉尼亚|马纳萨斯|俄亥俄|得克萨斯|[佐乔]治亚|亚特兰大|佛罗里达|迈阿密,America|United[^a-z]*States|Washington|Portland|Dallas|Oregon|Phoenix|Fremont|Valley|Francisco|Vegas|Los[^a-z]*Angeles|San[^a-z]*Jose|Santa[^a-z]*Clara|Seattle|Chicago|Columbus|York|Ashburn|Newark|Denver|California|Virginia|Manassas|Ohio|Texas|Atlanta|Florida|Miami
🇭🇰,HKG?|CMI|HGC|HKT|HKBN|WTT|PCCW,香港,Hong
🇯🇵,JPN?,日本|东京|大阪|名古屋|埼玉|福冈,Japan|Tokyo|Osaka|Nagoya|Saitama|Fukuoka
🇸🇬,SGP?,新加坡|[狮獅]城,Singapore
🇹🇼,TWN?|CHT|HiNet,[台臺][湾灣北]|新[北竹]|彰化|高雄,Taiwan|Taipei|Hsinchu|Changhua|Kaohsiung
🇷🇺,RUS?,俄[国國]|俄[罗羅]斯|莫斯科|圣彼得堡|西伯利亚|伯力|哈巴罗夫斯克,Russia|Moscow|Peters?burg|Siberia|Khabarovsk
🇬🇧,UK|GBR?,英[国國]|英格兰|伦敦|加的夫|曼彻斯特|伯克郡,Kingdom|England|London|Cardiff|Manchester|Berkshire
🇨🇦,CAN?,加拿大|[枫楓][叶葉]|多伦多|蒙特利尔|温哥华,Canada|Toronto|Montreal|Vancouver
🇫🇷,FRA?,法[国國]|巴黎|马赛|斯特拉斯堡,France|Paris|Marseille|Marselha|Strasbourg
🇰🇵,KP|PRK,朝[鲜鮮],North[^a-z]*Korea
🇰🇷,KO?R,[韩韓][国國]|首尔|春川,Korea|Seoul|Chuncheon
🇮🇪,IE|IRL,爱尔兰|都柏林,Ireland|Dublin
🇩🇪,DEU?,德[国國]|法兰克福|柏林|杜塞尔多夫,German|Frankfurt|Berlin|D[üu]sseldorf
🇮🇩,IDN?,印尼|印度尼西亚|雅加达,Indonesia|Jakarta
🇮🇳,IND?,印度|孟买|加尔各答|贾坎德|泰米尔纳德|海得拉巴|班加罗尔,India|Mumbai|Kolkata|Jharkhand|Tamil|Hyderabad|Bangalore
🇲🇲,MMR?|YGN,缅甸|[内奈]比[都多]|仰光,Myanmar|Naypyidaw|Nay[^a-z]*Pyi[^a-z]*Taw|Yangon|Rangoon
🇮🇱,IL|ISR,以色列|耶路撒冷,Israel|Jerusalem|Yerushalayim
🇦🇺,AUS?,澳大利[亚亞]|澳洲|悉尼|墨尔本|布里斯[班本],Australia|Sydney|Melbourne|Brisbane
🇦🇪,AR?E|UAE,阿联酋|迪拜|阿布扎比|富查伊拉,Emirates|Dubai|Dhabi|Fujairah
🇧🇦,BA|BIH,波黑|波[士斯]尼亚|[黑赫]塞哥维[纳那]|特拉夫尼克,Bosnia|Herzegovina|Travnik
🇧🇷,BRA?,巴西|圣保罗|维涅杜,Brazil|Paulo|Vinhedo
🇲🇴,MO|MAC|CTM,澳[门門],Maca[uo]
🇿🇦,ZAF?,南非|约(翰内斯)?堡,Africa|Johannesburg
🇨🇭,CHE?,瑞士|苏黎世|休伦堡|许嫩贝格,Switzerland|Zurich|H[üu]e?nenberg
🇸🇲,SMR?,圣[马玛][力丽][诺络],San[^a-z]*Marino
🇬🇶,GN?Q,赤道几内亚,Equatorial[^a-z]*Guinea
🇫🇮,FIN?,芬兰|赫尔辛基,Finland|Helsinki
🇹🇭,THA?,泰国|曼谷,Thailand|Bangkok
🇲🇽,ME?X,墨西哥|克雷塔罗,Mexico|Queretaro
🇸🇪,SW?E,瑞典|斯德哥尔摩,Sweden|Stockholm
🇹🇷,TU?R,土耳其|伊斯坦布尔,Turkey|Istanbul
🇸🇦,SAU?,沙特|吉达|利雅得,Arabia|J[eu]dda|Riyadh
🇱🇰,LKA?,斯里兰卡|[科哥可]伦坡,Sri[^a-z]*Lanka|Colombo
🇦🇹,AU?T,奥地利|维也纳,Austria|Vienna
🇴🇲,OMN?,阿曼|马斯喀特,Oman|Muscat
🇪🇸,ESP?,西班牙|马德里|巴塞罗那|[巴瓦]伦西亚,Spain|Madrid|Barcelona|Valencia
🇩🇴,DOM?,多[米明]尼加|圣多明[各哥戈],Dominican|Santo[^a-z]*Domingo
🇱🇮,LIE?,列支敦[士斯]登|瓦杜兹,Liechtenstein|Vaduz
🇧🇴,BOL?,玻利维亚|拉巴斯,Bolivia|La[^a-z]*Paz
🇩🇿,DZA?,阿尔及利亚|阿尔及尔,Algeria|Algiers
🇧🇾,BY|BLR,白俄?罗斯|明斯克,Belarus|Minsk
🇧🇸,BH?S,巴哈马|拿[骚索],Bahamas|Nassau
🇲🇹,ML?T,马耳他|瓦莱塔,Malta|Valletta
🇸🇮,SI|SVN,斯洛文尼亚|卢布尔雅那,Slovenia|Ljubljana
🇳🇱,NLD?,荷兰|阿姆斯特丹,Netherlands|Amsterdam
🇪🇪,EE|EST,爱沙尼亚|塔林,Estonia|Tallinn
🇷🇴,ROU?,罗马[尼利]亚|布加勒斯特,Romania|Bucharest
🇮🇹,ITA?,意大利|米兰|罗马|拉齐奥,Italy|Milan|Rome|Lazio
🇱🇺,LUX?,卢森堡,Luxembo?urg
🇵🇭,PHL?,菲律宾|马尼拉,Philippines|Manila
🇺🇦,UA|UKR,乌克兰|基辅,Ukraine|Kyiv|Kiev
🇦🇿,AZE?,阿塞拜疆,Azerbaijan
🇰🇬,KGZ?,吉尔吉斯斯坦,Kyrgyzstan
🇰🇿,KA?Z,哈萨克斯坦|阿斯塔纳,Kazakhstan|Astana
🇦🇬,AT?G,安提瓜和巴布达,Antigua
🇹🇲,TK?M,土库曼,Turkmenistan
🇦🇫,AFG?,阿富汗,Afghanistan
🇸🇧,SL?B,所罗门群岛,Solomon
🇷🇸,RS|SRB,塞尔维亚|贝尔格莱德,Serbia|Belgrade
🇺🇿,UZB?,乌兹别克斯坦,Uzbekistan
🇦🇷,ARG?,阿根廷|布宜诺,Argentina|Buenos
🇲🇰,MKD?,前南斯拉夫|马其顿|北马|斯科普里,Macedonia|Skopje
🇸🇰,SV?K,斯洛伐克|[布伯]拉[迪第提]斯拉[发瓦法],Slovensko|Bratislava
🇻🇪,VEN?,委内瑞拉|[加卡]拉[加卡]斯,Venezuela|Caracas
🇬🇱,GR?L,格[陵林]兰|努克,Greenland|Nuuk
🇵🇸,PSE?,巴勒斯坦,Palestine
🇧🇬,BGR?,保加利亚|索[非菲]亚,Bulgaria|Sofia
🇨🇴,COL?,哥伦比亚|波哥大,Colombia|Bogot[áa]
🇬🇮,GIB?,直布罗陀,Gibraltar
🇬🇹,GTM?,危地马拉,Guatemala
🇦🇶,AQ|ATA,南极,Antarctica
🇲🇪,MN?E,黑山|波德戈里察,Montenegro|Podgorica
🇿🇼,ZWE?,津巴布韦,Zimbabwe
🇰🇭,KHM?,柬埔寨|金边,Cambodia|Phnom[^a-z]*Penh
🇱🇹,LTU?,立陶宛|维尔纽斯,Lietuvos|Vilnius
🇧🇲,BMU?,百慕大,Bermuda
🇫🇴,FR?O,法罗群岛,Faroe
🇲🇳,MNG?,蒙古|乌兰巴托,Mongolia|Ulaanbaatar
🇲🇾,MYS?,马来|吉隆坡,Malaysia|Kuala
🇵🇰,PA?K,巴基斯坦|卡拉奇,Pakistan|Karachi
🇵🇹,PR?T,葡萄牙|里斯本|葡京,Portugal|Lisbon
🇸🇴,SOM?,索马里,Somalia
🇦🇼,AB?W,阿鲁巴,Aruba
🇩🇰,DN?K,丹麦|哥本哈根,Denmark|Copenhagen
🇮🇸,ISL?,冰岛|雷克雅[未维]克,Iceland|Reykjav[íi]k
🇦🇱,ALB?,阿尔巴尼亚|地拉那,Albania|Tirana
🇧🇪,BEL?,比利时|布鲁塞尔,Belgium|Brussels
🇬🇪,GEO?,格鲁吉亚|第比利斯,Georgia|Tbilisi
🇭🇷,HRV?,克罗地亚|萨格勒布,Croatia|Zagreb
🇭🇺,HUN?,匈牙利|布达佩斯,Hungary|Budapest
🇲🇩,MDA?,摩尔多瓦|基希讷乌,Moldova|Chi[șs]in[ăa]u
🇳🇬,NGA?,尼日利亚|拉各斯,Nigeria|Lagos
🇳🇿,NZL?,新西兰|奥克兰,Zealand|Auckland
🇧🇧,BR?B,巴巴多斯,Barbados
🇹🇳,TU?N,突尼斯,Tunisia
🇺🇾,UR?Y,乌拉圭|蒙得维的亚,Uruguay|Montevideo
🇻🇳,VNM?,越南|河内,Vietnam|Hanoi
🇪🇨,ECU?,厄瓜多尔|基多,Ecuador|Quito
🇲🇦,MAR?,摩洛哥|拉巴特,Morocco|Rabat
🇦🇲,AR?M,亚美尼亚|埃里温|耶烈万,Armenia|Yerevan
🇵🇱,PO?L,波兰|华沙,Poland|Warsaw
🇨🇾,CYP?,塞浦路斯|尼科西亚,Cyprus|Nicosia
🇪🇺,EUE?,欧[洲盟],Euro
🇬🇷,GRC?,希腊|雅典,Greece|Athens
🇯🇴,JOR?,约旦,Jordan
🇱🇻,LVA?,拉脱维亚|里加,Latvia|Riga
🇳🇴,NOR?,挪威|奥斯陆,Norway|Oslo
🇵🇦,PAN?,巴拿马,Panama
🇵🇷,PRI?,波多黎各,Puerto
🇧🇩,BG?D,孟加拉|达卡,Bengal|Dhaka
🇧🇳,BR?N,[文汶]莱,Brunei
🇧🇿,BL?Z,伯利兹,Belize
🇧🇹,BTN?,不丹,Bhutan
🇨🇱,CH?L,智利|圣地亚哥,Chile|Santiago
🇨🇷,CRI?,哥斯达黎加,Costa
🇨🇿,CZE?,捷克|布拉格,Czech|Prague
🇪🇬,EGY?,埃及|开罗,Egypt|Cairo
🇰🇪,KEN?,肯尼亚|内罗[毕比],Kenya|Nairobi
🇳🇵,NPL?,尼泊尔|加德满都,Nepal|Kathmandu
🇮🇲,IMN?,马恩岛|曼岛|道格拉斯,Isle[^a-z]*of[^a-z]*Man|Mann|Douglas
🇻🇦,VAT?,梵蒂冈,Vatican
🇮🇷,IRN?,伊朗|德黑兰,Iran|Tehran
🇵🇪,PER?,秘鲁|利马,Peru|Lima
🇱🇦,LAO?,老挝|寮国|万象|永珍,Lao|Vientiane
🇦🇩,AN?D,安道尔,Andorra
🇲🇨,MCO?,摩纳哥,Monaco
🇷🇼,RWA?,卢旺达,Rwanda
🇹🇱,TLS?,东帝汶,Timor
🇦🇴,AG?O,安哥拉,Angola
🇶🇦,QAT?,卡塔尔|多哈,Qatar|Doha
🇱🇾,LB?Y,利比亚,Libya
🇧🇭,BHR?,巴林|麦纳麦,Bahrain|Manama
🇾🇪,YEM?,也门,Yemen
🇸🇩,SDN?,苏丹,Sudan
🇨🇺,CUB?,古巴,Cuba
🇲🇱,MLI?,马里,Mali
🇫🇯,FJI?,斐济,Fiji
'''.splitlines()
re_emoji = [line.split(',') for line in map(str.strip, re_emoji) if line]
for i, (emoji, code, zh, en) in enumerate(re_emoji):
prefix = rf"emoji=^(?!.*{'(?!🇨🇳)' if emoji in ('🇭🇰', '🇹🇼', '🇲🇴') else ''}[🇦-🇿]{{2}}).*"
rest = re_emoji[i + 1:]
zh2 = rf"({zh}),"
if rest:
code_rest, zh_rest, en_rest = ('|'.join(rest) for rest in zip(*(x[1:] for x in rest)))
zh = rf"({zh})(?!中[轉转])(?!.*({zh_rest})(?!中[轉转])),"
en = rf"(?i:((?<![\da-z.])({code})(?!\d*[a-z])|{en})(?!.*((?<![\da-z.])({code_rest})(?!\d*[a-z])|{en_rest}))),"
else:
zh = rf"({zh})(?!中[轉转]),"
en = rf"(?i:((?<![\da-z.])({code})(?!\d*[a-z])|{en})),"
re_emoji[i] = [prefix + x + emoji for x in (zh, zh2, en)]
zh, zh2, en = map('\n'.join, zip(*re_emoji))
result = rf'''emoji=(?!🇨🇳)[🇦-🇿]{{2}},
{zh}
{zh2}
emoji=^(?!.*[🇦-🇿]{{2}}).*(美),🇺🇸
emoji=^(?!.*[🇦-🇿]{{2}}).*([中京沪滬申广廣深莞苏蘇杭厦廈海光川]德|德(?![\u4E00-\u9FFF])),🇩🇪
emoji=^(?!.*[🇦-🇿]{{2}}).*([中京沪滬申广廣深莞苏蘇杭厦廈海光川]俄|俄(?![\u4E00-\u9FFF])),🇷🇺
emoji=^(?!.*[🇦-🇿]{{2}}).*([中京沪滬申广廣深莞苏蘇杭厦廈海光川]印|印(?![\u4E00-\u9FFF])),🇮🇳
emoji=^(?!.*[🇦-🇿]{{2}}).*([韩韓]),🇰🇷
emoji=^(?!.*[🇦-🇿]{{2}}).*([中京沪滬申广廣深莞苏蘇杭厦廈海光川]日|(?<![\d\u4E00-\u9FFF])日(?![\u4E00-\u9FFF])),🇯🇵
emoji=^(?!.*[🇦-🇿]{{2}}).*([中京沪滬申广廣深莞苏蘇杭厦廈海光川]新|(?<![\u4E00-\u9FFF])新(?![\u4E00-\u9FFF])),🇸🇬
emoji=^(?!.*(?!🇨🇳)[🇦-🇿]{{2}}).*([中京沪滬申广廣深莞苏蘇杭厦廈海光川][台臺]|[台臺](?![\u4E00-\u9FFF])),🇹🇼
emoji=^(?!.*(?!🇨🇳)[🇦-🇿]{{2}}).*(港),🇭🇰
{en}
emoji=^(?!.*[🇦-🇿]{{2}}).*(中[国國]|[广廣贵貴]州|深圳|北京|上海|[广廣山][东東西]|[河湖][北南]|天津|重[庆慶]|[辽遼][宁寧]|吉林|黑[龙龍]江|江[苏蘇西]|浙江|安徽|福建|[海云雲]南|四川|[陕陝]西|甘[肃肅]|青海|[内內]蒙古|西藏|[宁寧]夏|新疆),🇨🇳
emoji=^(?!.*[🇦-🇿]{{2}}).*(?i:(?<![\da-z.])(CH?N|China)(?!\d*[a-z.])),🇨🇳
emoji=^(?!.*([🇦-🇿]{{2}}|ℹ️)).*(官.?网|官方|产品|平台|勿连|修复|恢复|更新|地址|网站|网址|域名|网域|浏览器|导航|搜|群|裙|聊|频道|电报|飞机|扣|微信|售后|客服|工单|联系|使用|购买|续费|订阅|公告|版本|出现|没网|情况|开通|数量|注|说明|通知|去除|过滤|@|:|(?i:(?<![\da-z])(tg|telegram|t\.me|qq?|vx?|wx)(?!\d*[a-z]|\d{{1,3}}(?!\d))|^[^:]+:(?![\da-f]{{0,4}}:|\s*\d{{1,5}}([/?]|\s*$)))),ℹ️
'''
for ini_file_name in (
'ACL4SSR_Online_Full_Mannix.ini',
'ACL4SSR_Online_Mannix.ini',
'ACL4SSR_Online_Full_Mannix_No_DNS_Leak.ini',
'ACL4SSR_Online_Mannix_No_DNS_Leak.ini',
):
with open(ini_file_name, 'r', encoding='utf-8') as f:
content = f.read()
content = re.sub(r'(?:^emoji=.*\n+?)+', lambda _: result, content, flags=re.MULTILINE)
with open(ini_file_name, 'w', encoding='utf-8', newline='') as f:
f.write(content)