Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/go-joe/cron
Cron jobs for the Joe bot library
https://github.com/go-joe/cron
bot chat chatbot-framework joe slack
Last synced: 3 days ago
JSON representation
Cron jobs for the Joe bot library
- Host: GitHub
- URL: https://github.com/go-joe/cron
- Owner: go-joe
- License: bsd-3-clause
- Created: 2019-03-30T10:31:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-03T08:48:28.000Z (over 4 years ago)
- Last Synced: 2024-07-04T02:45:28.412Z (6 months ago)
- Topics: bot, chat, chatbot-framework, joe, slack
- Language: Go
- Homepage: https://github.com/go-joe/joe
- Size: 30.3 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Joe Bot - Cron Module
Emiting events on recurring schedules. https://github.com/go-joe/joe
---
This repository contains a module for the [Joe Bot library][joe].
## Getting Started
This library is packaged as [Go module][go-modules]. You can get it via:
```bash
go get github.com/go-joe/cron
```### Example usage
This module allows you to run arbitrary functions or emit events on a schedule
using a [cron expressions][cron] or simply an interval expressed as `time.Duration`.```go
package mainimport (
"time"
"github.com/go-joe/joe"
"github.com/go-joe/cron"
)type MyEvent struct {}
func main() {
b := joe.New("example-bot",
// emit a cron.Event once every day at midnight
cron.ScheduleEvent("0 0 * * *"),
// emit your own custom event every day at 09:00
cron.ScheduleEvent("0 9 * * *", MyEvent{}),
// emit your own custom event every day at 09:00:30
cron.ScheduleEvent("30 0 9 * * *", MyEvent{}),// cron expressions can be hard to read and might be overkill
cron.ScheduleEventEvery(time.Hour, MyEvent{}),
// sometimes its easier to use a function
cron.ScheduleFunc("0 9 * * *", func() { /* TODO */ }),
// functions can also be scheduled on simple intervals
cron.ScheduleFuncEvery(5*time.Minute, func() { /* TODO */ }),
)
err := b.Run()
if err != nil {
b.Logger.Fatal(err.Error())
}
}
```## Built With
* [robfig/cron](https://github.com/robfig/cron) - A cron library for go
* [zap](https://github.com/uber-go/zap) - Blazing fast, structured, leveled logging in Go
* [testify](https://github.com/stretchr/testify) - A simple unit test library## Contributing
If you want to hack on this repository, please read the short [CONTRIBUTING.md](CONTRIBUTING.md)
guide first.## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available,
see the [tags on this repository][tags].## Authors
- **Friedrich Große** - *Initial work* - [fgrosse](https://github.com/fgrosse)
- **Julius Bachnick** - *Update cron library to v3* - [juliusbachnick](https://github.com/juliusbachnick)See also the list of [contributors][contributors] who participated in this project.
## License
This project is licensed under the BSD-3-Clause License - see the [LICENSE](LICENSE) file for details.
[joe]: https://github.com/go-joe/joe
[go-modules]: https://github.com/golang/go/wiki/Modules
[tags]: https://github.com/go-joe/cron/tags
[contributors]: https://github.com/go-joe/cron/contributors
[cron]: https://en.wikipedia.org/wiki/Cron#Overview