Skip to content

Commit

Permalink
Merge pull request #2 from fadenb/eslint_fixup
Browse files Browse the repository at this point in the history
ESLint error/warning fixes
  • Loading branch information
fadenb authored Oct 5, 2020
2 parents 135022a + 64c0be8 commit 772740d
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const core = require('@actions/core');
const github = require('@actions/github');

var sdk = require("matrix-js-sdk");
const sdk = require('matrix-js-sdk');

try {
const homeserver = core.getInput('homeserver');
Expand All @@ -10,37 +9,35 @@ try {
const message = core.getInput('message');
const messagetype = core.getInput('messagetype');


// Debug output
console.log(`homeserver: ${homeserver}`);
console.log(`channel: ${channel}`);
console.log(`token: ${token}`);
console.log(`message: ${message}`);
console.log(`messagetype: ${messagetype}`);
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
baseUrl: 'https://matrix.org',
accessToken: token,
});

// Join channel (if we are already in the channel this does nothing)
client.joinRoom(channel).then(function() {
console.log("Joined channel");
client.joinRoom(channel).then(() => {
console.log('Joined channel');
});

// Send message
const content = {
"msgtype": messagetype,
"body": message
msgtype: messagetype,
body: message,
};

client.sendEvent(channel, "m.room.message", content, "").then((res) => {
client.sendEvent(channel, 'm.room.message', content, '').then(() => {
// message sent successfully
}).catch((err) => {
console.log(err);
});

} catch (error) {
core.setFailed(error.message);
}

0 comments on commit 772740d

Please sign in to comment.