library(httr)
url = "https://hooks.slack.com/services/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"
httr::POST(url ,
body = list(
channel="#helms-deep",
text="Siege team ready to charge! Waiting for your order" ),
encode = "json")
Response [https://hooks.slack.com/services/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] Date: 2015-10-19 12:09 Status: 200 Content-Type: text/html Size: 2 B
library(slackr)
slackr_setup(channel="#helms-deep",
api_token = "xoxp-12726022931-12726023107-12731895792-fbc7665d3c",
icon_emoji = ":thumbsup:", username = "data-orc")
damage_report = data.frame(
seige_team = c(55,66,55),
archers = c(12,34,56),
healer=c(11,22,33),
row.names = c("injured", "dead", "respawned"))
damage_report
seige_team | archers | healer | |
---|---|---|---|
injured | 55 | 12 | 11 |
dead | 66 | 34 | 22 |
respawned | 55 | 56 | 33 |
slackr(damage_report)
barplot(rowSums(damage_report))
dev.slackr("#helms-deep")
Response [https://slack.com/api/files.upload] Date: 2015-10-19 13:00 Status: 200 Content-Type: application/json; charset=utf-8 Size: 1.56 kB
python-rtmbot/
├── doc
│ ├── example-config
│ ├── example-init
│ └── example-plugins ------------>範例程式,看過後比較知道怎麼寫
│ ├── canary.py
│ ├── counter.py
│ ├── repeat.py
│ └── todo.py
├── LICENSE.txt
├── plugins ---------------------->自己寫的code放這裡
│ └── warchief
│ └── repeat.py
├── README.md
├── requirements.txt
├── rtmbot.conf ----------------------------------------> token放這
└── rtmbot.py -------------------->主程式
python-rtmbot/plugins/warchief/repeat.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
crontable = []
outputs = []
def process_message(data):
if data['channel'] == 'C0CMFHF7Z' \
and "text" in data \
and data['text'].startswith("Warchief"):
action = data['text'].replace("Warchief, ", "")
reply = "Roger that! Orcs, let's %s!" % action
outputs.append([data['channel'], reply])