by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Garret Holland
@garretholland
@technicalpickles I see you all over the repos that are talking about what I'm trying to do - if you have any insight it would be much appreciated
Tim Kinnane
@timkinnane

@garretholland I'm late to the party and haven't completed followed all the details in your discussion above, but it sounds like what you might need is middleware to look at the context of listeners and possibly exit out of them before they resolve. The docs for listener middleware scripts are pretty useful. Also, the thing with listeners is that they only get an ID if you pass one in when you create it. You can pass an object to robot hear/respond between the regex and the callback, which will be available in the response object passed to the callback when it fires - or to the context of middleware processing wether or not to fire the callback at all.

https://github.com/github/hubot/blob/master/docs/scripting.md#listener-middleware-examples

Josh Nichols
@technicalpickles
@garretholland what's the question? I'm having a hard time parsing the back scroll
Garret Holland
@garretholland

@technicalpickles, basically I want to have a conversation with the bot and I'm trying to use a catch all regex for my second question, and it's creating a listener that remains after the conversation is done.

so the flow will go like this:
@bot account alias
bot: what's the account alias? <<<<<<<<--------this is the listener that I need to remove
@bot <alias>
bot: <provides account info>

what happens now is I can keep calling alias without using the initializer "account alias"

I have got as far as creating an ID, and then splicing it from the listeners array which I thought would do the trick, but I ran into another issue of code running when it shouldn't.. kinda hard to explain, I'll post my code and if we can talk interactively it may help

Basically the best way to remove listeners is what I'm looking for though
Garret Holland
@garretholland
I just started playing with hubot-conversation, but don't want to rely on a repo that may not be maintained, so coming up with a native solution is preferred
Garret Holland
@garretholland
 robot.respond(/account details/i, function(res) {
       //after initialized, ask for alias
        res.reply("Please provide account alias") 
             // second listener that's a catch all, set the ID for rmo--- this is the listener that is my issue
            robot.respond(/(.*)/i, { id: account details }, function(res) {
           // call to function in module, with callback, I seem to get stuck in this function
            v1.accountDetails(res2.match[1], function(body) {
                body = body.AccountDetails
                body = JSON.stringify(body, null, 4)
                body = body.replace(/[{}",]/g, '')
                res.reply(body)
                // how I'm removing the listener
                for(let i = 0; i < res.robot.listeners.length; i++) {
                     console.log('!!!!!!!!!!!!inside for loop')
                     if(res.robot.listeners[i].options.id === 'account details') {
                         console.log('!!!!!!!!!inside msg.robot.listeners if statement!!!!!!!!!')
                         res.robot.listeners.splice(i, 1)
                     }
                 }
                console.log('msg.robot.listeners array length after for loop 3rd ---------------->', res.robot.listeners.length)
            });
        })
    });
@technicalpickles
Josh Nichols
@technicalpickles
@garretholland you have probably determined this already, but there isn't really a good out of the box experience for this. you referenced github/hubot#950 as an example, and there is nothing new on that front
if I were to try to tackle this now, I would probably look at robot.listen, which you can customize when the listener matches. you could imagine another robot.respond putting something that then the other robot.listen checks for
that is kind of how https://github.com/ajacksified/how-to-hubot/blob/master/complete-example/node_modules/hubot-scripts/src/scripts/conversation.coffee works, but it is using receive middleware to do something similar
@garretholland in your code example, looks { id: account details } is missing quotes on account details
Josh Nichols
@technicalpickles
you also may want to scope that by the user and/or room that's calling it the first time
and also probably a setTimeout to remove it at some point
Garret Holland
@garretholland
sorry, I updated code to send to you, since I'm experimenting with hubot-conversation, it has quotes when utilziaing it
Josh Nichols
@technicalpickles
I could imagine someone saying acount details in one room, then switching to another room, saying something, and then hubot responding
in an unrelated context
Garret Holland
@garretholland
I agree, .. setTimeout removes the listener?
Josh Nichols
@technicalpickles
I'm saying you probably want to remove it after some amount of time if it hasn't been triggered
javascript's setTimeout would be the way to do something after a certain amount of time
Garret Holland
@garretholland
right.. alright I'm going to keep grinding away at this.. thank you for your input @technicalpickles
Garret Holland
@garretholland
This issue is going to drive me batty
I don't understand the way robot.listen works
Garret Holland
@garretholland
@timkinnane thank you for your reply as well. I am inserting an ID, and I'm able to access it successfully, where I'm at now is kind of hard to explain. .. let me run some code with some console logs
I'm just so all over the place trying to get something to work, I'm not on any solid footing
What I'm referencing above is - I create an ID, insert it, and loop through to remove it, that part is working, the problem is the next time I run 'account details' it just jumps right through to the catch all regex in the second robot.respond
Garret Holland
@garretholland
I'm trying to explain here and work, it's coming out too disjointed
I'll come back with a solid explanation
Josh Nichols
@technicalpickles
@garretholland you may find it helpful to look at how hubot's robot.respond calls robot.listen. There probably aren't many examples in the wild
Garret Holland
@garretholland
@technicalpickles thank you for your input, I do plan on digging in and figuring that out for future needs. For now I have settled on using hubot-conversation
robot.respond(/account details/i, { id: 'account details' }, function(res) {
        let dialog = switchboard.startDialog(res);

        res.reply("Please provide account alias") 
            dialog.addChoice(/(.*)/i, function(res2) {
                let str = res2.match[1].split(" ")
                alias = str[1]
                v1.accountDetails(alias, function(body) {
                    if(body.AccountDetails){
                        body = body.AccountDetails
                    }
                    body = JSON.stringify(body, null, 4)
                    body = body.replace(/[{}",]/g, '')
                    res2.reply(body)
                })
            })
    })
@mydigitalself ^ this is how I got it working
Mike Bartlett
@mydigitalself
@garretholland ah cool!
Prateek Saxena
@prtksxna
I am not able to setup hubot for gitter https://dpaste.de/yG0j. I am trying to use the gitter2 adapter here.
When I use the older one (https://github.com/kcjpop/hubot-gitter) there is no output whatsoever. Any ideas on what I might be doing wrong?
Brandon Keepers
@bkeepers
@prtksxna are you on Windows?
Prateek Saxena
@prtksxna
@bkeepers Nope
@bkeepers I am now trying to use https://www.npmjs.com/package/hubot-gitter2-patched
@bkeepers This shows be a ton of useful logs, like the users in the room etc, and doesn't fail with an error, but still does not respond to messages
Whenever there is a new message, instead of responding to it, all I see in the log is [hubot-gitter2.debug][object GitterClient<9b...f8>] found user with id5911b57cd73408ce4f5e2534: [object GitterUser<thegirlfromfuss>]
Prateek Saxena
@prtksxna
Seems like a version of huafu/hubot-gitter2#9, but I am passing a name that matches the github user
Brandon Keepers
@bkeepers
Hey everyone, just wanted to give a heads up that we’ve moved the official Hubot room over to Slack: github/hubot#1322
Bikram Bhattacharya
@bikrambhattacharya
help needed. anyone? how to find a file in a big database with issue #425
lswen
@lswen
Hhhhhh
Bhavam
@Bhavam
ggi
AKHOND-ZADA
@Akhond-Zada
My credit card details why it is declined now
Priyanka Jain
@Priya997
hey
anyone here
Zhang Qijie
@abetterman
hello guys
Tim Erickson
@stpaultim
There isn’t much action here.