- Tomaz Muraus (Kami)
- Engineer at StackStorm
- Previously: Cloudkick, Rackspace, DivvyCloud
- Likes: Distributed systems, open standards and open source systems, startups, tinkering / "hacking" 80's music, working out
... def _handle_pubmsg(self, connection, event): trigger = 'irc.pubmsg' payload = { 'source': { 'nick': event.source.nick, 'host': event.source.host }, 'channel': event.target, 'timestamp': event.timestamp, 'message': event.arguments[0] } self._sensor_service.dispatch(trigger=trigger, payload=payload) ...
{ "source": { "nick": "Kami__", "host": "gateway/web/irccloud.com/x-uvv" }, "channel": "#test989", "timestamp": 1419166748, "message": "this is a test message" }
import httplib import requests from st2actions.runners.pythonrunner import Action SEND_EMAIL_API_URL = 'https://api.mailgun.net/v2/%(domain)s/messages' class SendEmailAction(Action): def run(self, sender, recipient, subject, text, html=None): domain = self.config['domain'] api_key = self.config['api_key'] data = { 'from': sender, 'to': recipient, 'subject': subject, 'text': text } if html: data['html'] = html api_url = SEND_EMAIL_API_URL % {'domain': domain} response = requests.post(api_url, auth=('api', api_key), data=data) return response.status_code == httplib.OK
--- name: "relayed_matched_irc_message" description: "Relay IRC message to Slack if the message contains word StackStorm" enabled: true trigger: type: "irc.pubmsg" parameters: {} criteria: trigger.message: type: "icontains" pattern: "StackStorm" action: ref: "slack.post_message" parameters: message: "{{trigger.source.nick}} on {{trigger.channel}}: {{trigger.message}}" channel: "#irc-relay"