34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
path = r"E:\GitHub\blog\bot-go\internal\tghandlers\tghandlers.go"
|
|
with open(path, "rb") as f:
|
|
content = f.read().decode("utf-8")
|
|
|
|
# Fix line 117: non-boolean condition
|
|
# The Stop function was using writeserver.StopWriteServer() which returned bool
|
|
# Now it's replaced with a SendMessage call which returns error
|
|
# Fix:
|
|
|
|
old_stop = ''' if tgcore.SendMessage(chatID, "WriteServer stop not available in bot-only mode.", nil) {
|
|
tgcore.SendMessage(chatID, "⚡ Write 已停止。", nil)
|
|
} else {
|
|
tgcore.SendMessage(chatID, "⏸ Write 未运行。", nil)
|
|
}'''
|
|
|
|
new_stop = ''' tgcore.SendMessage(chatID, "WriteServer 已与 Bot 合并,无需单独启停。", nil)'''
|
|
|
|
content = content.replace(old_stop, new_stop)
|
|
|
|
# Fix line 578: cannot index result
|
|
# Find the problematic line around 578
|
|
lines = content.split("\n")
|
|
for i, line in enumerate(lines):
|
|
if i >= 575 and i <= 582:
|
|
print(f" {i+1}: {line}")
|
|
|
|
# Fix writeserver.GetWriteStatus() replacement - it was replaced with a map literal
|
|
# but used in an if condition
|
|
content = content.replace('if s := map[string]interface{}{"running": true, "starting": false};', 'if s := tgcore.GetWriteStatus();')
|
|
|
|
with open(path, "wb") as f:
|
|
f.write(content.encode("utf-8"))
|
|
print("\nFixed Stop and GetWriteStatus")
|