commit 124a427f59ae13d3c28b317cca6c542690ce10e1
parent 218d845baa43a9bdd102f120928029f67d8e5fbd
Author: bsandro <email@bsandro.tech>
Date: Sun, 6 Nov 2022 14:12:51 +0200
Recording forwarded messages
Diffstat:
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/main.go b/main.go
@@ -88,7 +88,26 @@ func writeLog(msg *tgbotapi.Message, mtx *sync.Mutex) {
}
defer logfile.Close()
t := ts.Format("2006-01-02 15:04:05")
- logstr := fmt.Sprintf("[%s][%s] %s\n", t, fromName, msg.Text)
+ logstr := fmt.Sprintf("[%s][%s]", t, fromName)
+
+ if msg.ForwardFromChat != nil {
+ logstr += "(-> " + msg.ForwardFromChat.Title + ")"
+ }
+
+ if msg.ForwardFrom != nil {
+ logstr += "(-> " + msg.ForwardFrom.FirstName + " " + msg.ForwardFrom.LastName + ")"
+ }
+
+ if msg.Caption != "" {
+ logstr += "{" + msg.Caption + "}"
+ }
+
+ if msg.Text != "" {
+ logstr += " " + msg.Text
+ }
+
+ logstr += "\n"
+
if _, err := logfile.WriteString(logstr); err != nil {
log.Println(err)
}