Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit Message #314

Open
ZyC0R3 opened this issue Mar 18, 2019 · 0 comments
Open

Edit Message #314

ZyC0R3 opened this issue Mar 18, 2019 · 0 comments

Comments

@ZyC0R3
Copy link

ZyC0R3 commented Mar 18, 2019

I am trying to get a script to edit a message, if my user puts #1234 i would like the message to be eddied by the bot to become https:linkaddress.address/show_bug.cgi?id=1234

i found this code in another ticket that was raised but it does not seem to work. unless i am doing it wrong

module.exports = (robot) ->
    robot.hear /#([\d]+)/i, (msg) ->

        # Link to the associated bug
        issueId = msg.match[1]
        updatedMsg = msg.message.text.replace("##{issueId}", "[##{issueId}](https://linkaddress.address/show_bug.cgi?id=#{issueId}"

       # Call edit.  (bot will have to have the permission to do this)
        robot.adapter.callMethod('updateMessage',
            _id: msg.message.id
            rid: msg.message.room
            msg: updatedMsg
        ).catch (err) ->
           console.error err

I treid to convert it to JS and got this

module.exports = function(robot) {
  return robot.hear(/#([\d]+)/i, function(msg) {
    var issueId, updatedMsg;
    issueId = msg.match[1];
    return updatedMsg = msg.message.text.replace("#" + issueId, "[#" + issueId + "](https://linkaddress.address/show_bug.cgi?id=" + issueId, robot.adapter.callMethod('updateMessage', {
      _id: msg.message.id,
      rid: msg.message.room,
      msg: updatedMsg
    })["catch"](function(err) {
      return console.error(err);
    }));
  });
};

Neither work, am i missing somthing, any help would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant