hyphacoop / hyphacoop-chatbot

A friendly helper robot that lives in Hypha's chat rooms
https://hyphacoop-chatbot.herokuapp.com
0 stars 0 forks source link

Git Hub Questions - Proof of concept #10

Open YurkoWasHere opened 5 years ago

YurkoWasHere commented 5 years ago

Code that will output "### :question:" items into the INTERNAL chat from a specified date Right now its triggered by @botname test

TODO

module.exports = (robot) ->
  robot.respond /TEST (.*)\??/i, (msg) ->
     robot.http("https://api.github.com/repos/hyphacoop/organizing/issues/comments?sort=created&direction=desc&since=2019-10-31T00:00:00Z")
         .get() (err,res,body) ->
             result = JSON.parse body
             for key,value of result
                 if value.body.indexOf("### \u2753") > -1

                     body=value.body.split "\r\n"
                     title=body[0];
                     url=value.html_url
                     user=value.user.login
                     at=body[1]

                     text=at + " - " + title + " - " + url
                     robot.messageRoom '!JloFJtoONurMdgcZCa:tomesh.net', text
YurkoWasHere commented 5 years ago

Note:

To message a specific room in Matrix you need the internal room id

robot.messageRoom '!JloFJtoONurMdgcZCa:tomesh.net', "text"

The internal room ID can be aquired by right clicking in RIOT on the room, Settings, Advanced, you will see a Internal room ID