-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Botters Engine | ||
|
||
Botters is a bot engine designed to siplify the process of creating Slack bots. | ||
Botters bots handle a single conversation, reading input on stdin and writing | ||
responses on stdout. (Think [inetd](https://en.wikipedia.org/wiki/Inetd) for | ||
Slack conversations.) Botters launches multiple instances of the bots on demand, | ||
one for each individual conversation. Conversations terminate when the bot | ||
exits. | ||
|
||
Botters bots can be very simple. This is the complete code for a working bot | ||
which keeps track of when was the last time someone mentioned "ChatGPT" in the | ||
channel: | ||
|
||
```bash | ||
#!/bin/bash | ||
|
||
LAST_MENTION= | ||
|
||
while :; do | ||
read MSG | ||
if [[ "$MSG" = *ChatGPT* ]]; then | ||
NOW=$( date +'%s' ) | ||
if [[ -n "$LAST_MENTION" ]]; then | ||
echo "It has been $(( NOW - LAST_MENTION )) seconds since someone mentioned ChatGPT last!" | ||
fi | ||
LAST_MENTION="$NOW" | ||
fi | ||
|
||
sleep 0.1 | ||
done | ||
``` | ||
|
||
See [examples](examples) for more examples. |