35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from pathlib import Path
|
||
import shutil
|
||
|
||
p = Path('/opt/kick-duel/server.js')
|
||
t = p.read_text(encoding='utf-8')
|
||
if "handleFdpi" in t:
|
||
print('FDPI command already present')
|
||
raise SystemExit(0)
|
||
|
||
needle = " handleWebsite (name) {"
|
||
handler = ''' handleFdpi (name) {
|
||
const message = `⚡ @${name}, LD FDPI: DPI bypass + AmneziaWG VPN, WFP kill-switch, DNS/IPv6 koruması. https://ttmadethat.shop/ld-fdpi`;
|
||
if (this.bot && typeof this.bot.queue === 'function') {
|
||
this.bot.queue(message).catch((err) => log('FDPI mesaji hatasi:', err.message));
|
||
} else {
|
||
this.notice(message, 'fdpi');
|
||
}
|
||
log(`FDPI linki gonderildi: ${name}`);
|
||
return true;
|
||
}
|
||
|
||
'''
|
||
if needle not in t:
|
||
raise SystemExit('handleWebsite anchor not found')
|
||
t = t.replace(needle, handler + needle, 1)
|
||
|
||
branch_needle = " if (command === 'website') {\n this.handleWebsite(name);\n return;\n }\n"
|
||
branch = branch_needle + "\n if (command === 'fdpi' || command === 'ldfdpi') {\n this.handleFdpi(name);\n return;\n }\n"
|
||
if branch_needle not in t:
|
||
raise SystemExit('website branch not found')
|
||
t = t.replace(branch_needle, branch, 1)
|
||
|
||
shutil.copy2(p, '/opt/kick-duel/server.js.bak-fdpi-command')
|
||
p.write_text(t, encoding='utf-8')
|
||
print('FDPI command added')
|