# Fix stop function - the old replacement didn't work due to line breaks path = r"E:\GitHub\blog\bot-go\internal\tghandlers\tghandlers.go" with open(path, "rb") as f: content = f.read().decode("utf-8") # The Stop function has: # if tgcore.SendMessage(chatID, "WriteServer stop not available...", nil) { # This is wrong because SendMessage returns error not bool # Fix: just call SendMessage directly import re # Match the whole if block pattern = r'if tgcore\.SendMessage\(chatID, "WriteServer stop not available in bot-only mode\..*?\n\t\}' content = re.sub(pattern, 'tgcore.SendMessage(chatID, "WriteServer \u5df2\u4e0e Bot \u5408\u5e76\uff0c\u65e0\u9700\u5355\u72ec\u542f\u505c\u3002", nil)', content, flags=re.DOTALL) # Fix the Status function - line 578/578 # Looking for: if s := map[string]interface{}{"running": true, ...}; !s["running"] # This was the replacement for writeserver.GetWriteStatus() old_status = 'if s := map[string]interface{}{"running": true, "starting": false};' new_status = 's := map[string]interface{}{"running": true, "starting": false}; if' content = content.replace(old_status, new_status) # Also fix other Status references content = content.replace('"running"].(bool)', '["running"].(bool)') content = content.replace('s["running"]', 's["running"]') with open(path, "wb") as f: f.write(content.encode("utf-8")) print("Fixed Stop and Status")