From d65d5d3c5273a007d907e3178d011b3a7dc9987d Mon Sep 17 00:00:00 2001 From: Tristan Helmich Date: Tue, 6 Oct 2020 12:21:55 +0000 Subject: [PATCH] Add file to test ESLint check and annotations --- ESLINT-TEST.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ESLINT-TEST.js diff --git a/ESLINT-TEST.js b/ESLINT-TEST.js new file mode 100644 index 0000000..b6bdb09 --- /dev/null +++ b/ESLINT-TEST.js @@ -0,0 +1,43 @@ +const core = require('@actions/core'); + +const sdk = require('matrix-js-sdk'); + +try { + const homeserver = core.getInput('homeserver'); + const channel = core.getInput('channel'); + const token = core.getInput('token'); + const message = core.getInput('message'); + const messagetype = core.getInput('messagetype'); + + // Debug output + core.info(`homeserver: ${homeserver}`); + core.info(`channel: ${channel}`); + core.info(`token: ${token}`); + core.info(`message: ${message}`); + core.info(`messagetype: ${messagetype}`); + + // Create client object + const client = sdk.createClient({ + baseUrl: "https://matrix.org", + accessToken: token + }); + + // Join channel (if we are already in the channel this does nothing) + client.joinRoom(channel).then(() => { + console.log('Joined channel'); + }); + + // Send message + const content = { + msgtype: messagetype, + body: message, + }; + + client.sendEvent(channel, 'm.room.message', content, '').then(() => { + // message sent successfully + }).catch((err) => { + console.log(err); + }); +} catch (error) { + core.setFailed(error.message); +}