alarm.go 664 B

123456789101112131415161718192021222324252627282930
  1. package tool
  2. import (
  3. "database/sql"
  4. )
  5. func Send_alarm(db *sql.DB, from string, target string, data string) {
  6. if from != target {
  7. data = from + " | " + data
  8. now_time := Get_time()
  9. count := "1"
  10. QueryRow_DB(
  11. db,
  12. "select id from user_notice where name = ? order by id + 0 desc limit 1",
  13. []any{ &count },
  14. target,
  15. )
  16. count_int := Str_to_int(count)
  17. count_int += 1
  18. Exec_DB(
  19. db,
  20. "insert into user_notice (id, name, data, date, readme) values (?, ?, ?, ?, '')",
  21. count_int, target, data, now_time,
  22. )
  23. }
  24. }