main.go 756 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "fmt"
  4. "time"
  5. "git.wenlab.co/joe/beaconfire"
  6. "git.wenlab.co/joe/beaconfire/providers"
  7. )
  8. func main() {
  9. // multi channels
  10. var bfs []beaconfire.BeaconFire
  11. // workwx
  12. wx := providers.NewWorkWx(&providers.OptionsWorkwx{
  13. Key: "xfdd",
  14. })
  15. // telegram
  16. tg := providers.NewTelegram(&providers.OptionsTelegram{
  17. Token: "ttt",
  18. })
  19. // together
  20. bfs = append(bfs, wx, tg)
  21. // send
  22. var err error
  23. var name string
  24. for _, bf := range bfs {
  25. // checker original
  26. name = bf.Name()
  27. if name == providers.TELEGRAM_NAME {
  28. fmt.Println("telegram sending ...")
  29. }
  30. // send
  31. err = bf.Send(beaconfire.NewBeaconParam("subject", "im a message", time.Now().Unix(), ""))
  32. if err != nil {
  33. // log
  34. fmt.Println("Error:", err)
  35. }
  36. }
  37. }