input: discord: channel_id: ${DISCORD_CHANNEL:xxx} bot_token: ${DISCORD_BOT_TOKEN:xxx} cache: request_tracking cache_key: last_message_received pipeline: processors: - switch: - check: this.type == 7 processors: - bloblang: | root = "Welcome to the Benthos Blobchat server <@%v>! We'd love to hear your story over in <#853284952261918773>.".format(this.author.id) - check: this.content == "/commands" processors: - bloblang: | let commands = [ "/commands", "/joke", "/roast", "/release", ] root = "My commands are: " + $commands.join(", ") - check: this.content == "/joke" processors: - bloblang: | let jokes = [ "What do you call a belt made of watches? A waist of time.", "What does a clock do when it’s hungry? It goes back four seconds.", "A company is making glass coffins. Whether they’re successful remains to be seen.", ] root = $jokes.index(timestamp_unix_nano() % $jokes.length()) - check: this.content == "/roast" processors: - bloblang: | let roasts = [ "If <@%v>'s brain was dynamite, there wouldn’t be enough to blow their hat off.", "Someday you’ll go far <@%v>, and I really hope you stay there.", "I’d give you a nasty look, but you’ve already got one <@%v>.", ] root = $roasts.index(timestamp_unix_nano() % $roasts.length()).format(this.author.id) - check: this.content == "/release" processors: - bloblang: 'root = ""' - try: - http: url: https://api.github.com/repos/redpanda-data/benthos/releases/latest verb: GET - bloblang: 'root = "The latest release of Benthos is %v: %v".format(this.tag_name, this.html_url)' - processors: - bloblang: 'root = deleted()' - catch: - log: fields_mapping: | root.error = error() message: "Failed to process message" - bloblang: 'root = "Sorry, my circuits are all bent from twerking and I must have malfunctioned."' output: discord: channel_id: ${DISCORD_CHANNEL:xxx} bot_token: ${DISCORD_BOT_TOKEN:xxx} cache_resources: - label: request_tracking file: directory: /tmp/discord_bot