Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@raws
Last active June 9, 2021 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raws/2a27d750437c5aa8cc674a3c38698e0e to your computer and use it in GitHub Desktop.
Save raws/2a27d750437c5aa8cc674a3c38698e0e to your computer and use it in GitHub Desktop.
Quick demo of responding to bot mentions using Wonder Llama: https://github.com/raws/wonder-llama
require 'bundler/inline'
gemfile do
gem 'wonder-llama', github: 'raws/wonder-llama', branch: 'master', require: 'wonder_llama'
end
def bot_mentioned?(message)
message.content.include?('@**Ralph**')
end
client = WonderLlama::Client.new(host: ENV['ZULIP_HOST'], email: ENV['ZULIP_EMAIL'],
api_key: ENV['ZULIP_API_KEY'])
client.stream_events do |event|
if event.is_a?(WonderLlama::MessageEvent) && (event.message.private? || bot_mentioned?(event.message))
sender = event.message.params[:sender_full_name]
event.message.reply("Hi there, @**#{sender}**! :wave:")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment