Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Api Slack
- os.loadAPI("json")
- function getUserName(userId)
- src=http.get("https://slack.com/api/users.info?token=xoxb-98445457363-RuBmedToi74xaAZxHK2X5RXg&user="..userId.."&pretty=1").readAll()
- t=json.decode(src)
- if not(t.ok) then
- return
- else
- return t.user.name
- end
- end
- function getLastMessage(channel)
- channel = channel or "C2T0N7H7S"
- src=http.get("https://slack.com/api/channels.history?token=xoxb-98445457363-RuBmedToi74xaAZxHK2X5RXg&channel="..channel.."&pretty=1").readAll()
- t=json.decode(src)
- if not(t.ok) then
- return nil
- else
- user = t["messages"][1]["user"]
- if user==nil then
- user = t["messages"][1]["username"]
- end
- return t["messages"][1]["text"],user
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement