litaio / lita-hipchat

A HipChat adapter for Lita.
MIT License
38 stars 27 forks source link

Treat private messages as commands #29

Open AureliusTech opened 9 years ago

AureliusTech commented 9 years ago

Hi -- I'm new to lita and lita-hipchat. I've got a basic setup running with the google images plugin and most all is well. However, when I start a private chat with my bot, I still have to prefix my commands with @bot to have them executed. Is this the expected behavior? Is it possible to have a setting which causes all private chat to be treated as a command? Is this configured at the lita level or the lita-hipchat level?

thanks!

jimmycuadra commented 9 years ago

This shouldn't be necessary. It's possible you've come across a bug. Could you provide your lita_config.rb file (sans any private information) to help diagnose?

AureliusTech commented 9 years ago

Hi -- Thanks for your help.

It's a pretty vanilla config:

Lita.configure do |config|
  # The name your robot will use.
  config.robot.name = "AU Robot"

  # The locale code for the language to use.
  # config.robot.locale = :en

  # The severity of messages to log. Options are:
  # :debug, :info, :warn, :error, :fatal
  # Messages at the selected level and above will be logged.
  config.robot.log_level = :debug

  config.robot.adapter = :hipchat
  config.adapters.hipchat.jid = "suppressed@chat.hipchat.com"
  config.adapters.hipchat.password = "supressed"
  config.adapters.hipchat.debug = true
  config.adapters.hipchat.rooms = :all
  #config.adapters.hipchat.private_chat = true ## a stab in the dark...didn't work

end

I suppose that won't help much.... Maybe there is some issue with the name having a space...? (It is the value of the Jabber Room nickname listed in the XMPP settings page.

Here are the current version of the Gem's I'm using

Using rake 10.4.2
Using oauth 0.4.7
Using gmail_xoauth 0.4.1
Using mime-types 2.6.1
Using mail 2.6.3
Using gmail 0.6.0
Using au_infra 0.2.0 from source at ../au_infra
Using bundler 1.10.6
Using diff-lcs 1.2.5
Using unf_ext 0.0.7.1
Using unf 0.1.4
Using domain_name 0.5.24
Using multipart-post 2.0.0
Using faraday 0.9.1
Using http-cookie 1.0.2
Using rack 1.6.4
Using url_mount 0.2.1
Using http_router 0.11.2
Using i18n 0.7.0
Using ice_nine 0.11.1
Using multi_json 1.11.2
Using puma 2.13.4
Using rb-readline 0.5.3
Using redis 3.2.1
Using redis-namespace 1.5.2
Using thor 0.19.1
Using lita 4.6.1
Using lita-google-images 2.0.0
Using xmpp4r 0.5.6
Using lita-hipchat 3.0.0
Using mrdialog 1.0.1
Using netrc 0.10.3
Using rest-client 1.8.0
Using rspec-support 3.3.0
Using rspec-core 3.3.2
Using rspec-expectations 3.3.1
Using rspec-mocks 3.3.2
Using rspec 3.3.0
AureliusTech commented 9 years ago

Here are the logs -- two commands are issued, both thru private chat -- the first has an @bot prefix, the second does not

D, [2015-09-10T10:27:49.047306 #50524] DEBUG -- : TRYING stanzacbs...
D, [2015-09-10T10:27:49.047328 #50524] DEBUG -- : TRYING message/iq/presence/cbs...

##Command with prefix:

D, [2015-09-10T10:28:10.516056 #50524] DEBUG -- : RECEIVED:
    <message from='suppressed8@chat.hipchat.com/iphone||proxy|proxy-e106.hipchat.com|5272' mid='XXX' to='suppressed@chat.hipchat.com' ts='1441895290.513747' type='chat'><body>@bot image car</body><active xmlns='http://jabber.org/protocol/chatstates'/></message>
D, [2015-09-10T10:28:10.516450 #50524] DEBUG -- : PROCESSING:
    <message from='suppressed8@chat.hipchat.com/iphone||proxy|proxy-e106.hipchat.com|5272' mid='XXX' to='suppressed@chat.hipchat.com' ts='1441895290.513747' type='chat' xmlns='jabber:client'><body>@bot image car</body><active xmlns='http://jabber.org/protocol/chatstates'/></message> (Jabber::Message)

D, [2015-09-10T10:28:10.516483 #50524] DEBUG -- : TRYING stanzacbs...
D, [2015-09-10T10:28:10.516505 #50524] DEBUG -- : TRYING message/iq/presence/cbs...

[2015-09-10 14:28:10 UTC] DEBUG: Looking up user with JID: suppressed8@chat.hipchat.com/iphone||proxy|proxy-e106.hipchat.com|5272.
[2015-09-10 14:28:10 UTC] DEBUG: Dispatching PM to Lita from suppressed8@chat.hipchat.com.
[2015-09-10 14:28:10 UTC] DEBUG: Dispatching message to Lita::Handlers::GoogleImages#fetch.
[2015-09-10 14:28:11 UTC] DEBUG: Sending message to JID suppressed8@chat.hipchat.com: http://media.caranddriver.com/images/media/51/dissected-lotus-based-infiniti-emerg-e-sports-car-concept-top-image-photo-451994-s-original.jpg
D, [2015-09-10T10:28:11.998406 #50524] DEBUG -- : SENDING:
    <message to='suppressed8@chat.hipchat.com' type='chat' xmlns='jabber:client'><body>http://media.caranddriver.com/images/media/51/dissected-lotus-based-infiniti-emerg-e-sports-car-concept-top-image-photo-451994-s-original.jpg</body></message>

##Command with out prefix --> no results
D, [2015-09-10T10:28:19.377174 #50524] DEBUG -- : RECEIVED:
    <message from='suppressed8@chat.hipchat.com/iphone||proxy|proxy-e106.hipchat.com|5272' mid='XXX' to='suppressed@chat.hipchat.com' ts='1441895299.382107' type='chat'><body>Image car</body><active xmlns='http://jabber.org/protocol/chatstates'/></message>
D, [2015-09-10T10:28:19.377623 #50524] DEBUG -- : PROCESSING:
    <message from='suppressed8@chat.hipchat.com/iphone||proxy|proxy-e106.hipchat.com|5272' mid='XXX' to='suppressed@chat.hipchat.com' ts='1441895299.382107' type='chat' xmlns='jabber:client'><body>Image car</body><active xmlns='http://jabber.org/protocol/chatstates'/></message> (Jabber::Message)
D, [2015-09-10T10:28:19.377660 #50524] DEBUG -- : TRYING stanzacbs...
D, [2015-09-10T10:28:19.377684 #50524] DEBUG -- : TRYING message/iq/presence/cbs...
[2015-09-10 14:28:19 UTC] DEBUG: Looking up user with JID: suppressed8@chat.hipchat.com/iphone||proxy|proxy-e106.hipchat.com|5272.
[2015-09-10 14:28:19 UTC] DEBUG: Dispatching PM to Lita from suppressed8@chat.hipchat.com.
AureliusTech commented 9 years ago

As a side note -- when in private chat mode or otherwise, it would be useful for lita to respond with some sort of message when it doesn't understand a command e.g. @bot jump --> in my current setup this message is silently ignored -- thanks!