errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.13k stars 616 forks source link

Hipchat backend throwing errors on mentions #788

Closed ramonamis closed 8 years ago

ramonamis commented 8 years ago

Hello,

I upgrade errbot to 4.2.3 and this time the upgrade worked really smooth, except i have an issue with the hipchat backend. It keeps throwing this error to log and even if it does not have any side effect right now I would like to get a hint on what is causing it and how can i fix it.

16:01:34 ERROR    sleekxmpp.xmlstream.xmlst Error processing event handler: <bound method HipchatBackend.incoming_message of <yapsy_loaded_plugin_Hipchat_0.HipchatBackend object at 0x7f344564fe50>>
Traceback (most recent call last):
  File "/home/hildasan/.virtualenvs/hilda-san-env/local/lib/python2.7/site-packages/sleekxmpp/xmlstream/xmlstream.py", line 1699, in _event_runner
    func(*args)
  File "/home/hildasan/.virtualenvs/hilda-san-env/local/lib/python2.7/site-packages/errbot/backends/xmpp.py", line 459, in incoming_message
    self.callback_message(msg)
  File "/home/hildasan/.virtualenvs/hilda-san-env/local/lib/python2.7/site-packages/errbot/backends/hipchat.py", line 415, in callback_message
    ifilter(None.__ne__, [self._find_user(mention[1:], u'mention_name') for mention in possible_mentions])
AttributeError: 'NoneType' object has no attribute '__ne__'

Best, Ramona

gbin commented 8 years ago

Thanks for the report ...hmm this must be a python 2 only bug. I am checking it out. Meanwhile, do you have anything that pins you to python 2 or upgrading to python 3 is easy ? (we gonna stop supporting python 2 at the end of the year)

gbin commented 8 years ago

Can you try the proposed fix in #790 ?

ramonamis commented 8 years ago

I tried the fix but it does not work. Suddenly i get rate limited from hipchat, as soon as i revert the change i am not rate limited anymore.

/home/hildasan/.virtualenvs/hilda-san-env/local/lib/python2.7/site-packages/hypchat/__init__.py:47: RateLimitWarning: HipChat has been rate limited; Waiting 259.8s for the next reset.
  warnings.warn("HipChat has been rate limited; Waiting %0.1fs for the next reset." % t, RateLimitWarning)

Also, when it actually connects, it does not react to commands at all. :(

I am stuck with python 2.7 at the moment because the bot is running on a build machine and the apps build only with python 2.7. I am aware you will not continue supporting it, and thinking about a different setup.

gbin commented 8 years ago

wut? do you do something on mentions ?

gbin commented 8 years ago

Can you put the log level on debug and looks at what requests Errbot is doing ? (it doesn't make any sense because the mention change caches API calls so it cannot be that)

ramonamis commented 8 years ago

I put the loglevel into debug and i really can not find anything, and it does not make any sense.

15:50:39 DEBUG    requests.packages.urllib3 "GET /v2/room?expand=items HTTP/1.1" 429 174
/home/hildasan/.virtualenvs/hilda-san-env/local/lib/python2.7/site-packages/hypchat/__init__.py:47: RateLimitWarning: HipChat has been rate limited; Waiting 195.0s for the next reset.
  warnings.warn("HipChat has been rate limited; Waiting %0.1fs for the next reset." % t, RateLimitWarning)
15:50:44 DEBUG    sleekxmpp.xmlstream.xmlst RECV: <presence from="61338_1764857@chat.hipchat.com/mac_macweb||proxy|proxy-d314.hipchat.com|5282" type="unavailable" to="3476548327t@chat.hipchat.com/none||proxy|pubproxy-b300.hipchat.com|5272"><mobile xmlns="http://hipchat.com/protocol/presence" type="android" /></presence>
15:50:49 DEBUG    errbot.botplugin          Previous timer found and removed
15:50:49 DEBUG    errbot.botplugin          Previous timer found and removed

These are the only logs around that event. As soon as i remove the fix everything just works.

ramonamis commented 8 years ago

OK so actually the fix WORKS, yey.

I think i found out why i get hipchat rate limited, i will open a separate issue. I got rate limited with or without the fix in the end, so it was just more of a persistent coincidence.

Thanks a lot, you can close this issue!

EDIT: no need to create new issue. how i got rate limited was the following: my chatroom_presence was using jid instead of name, and then the hypchat backend would always query hipchat to get the room name from the JID, resulting in rate limiting. at this point just joining rooms by the room if seems to decrease the number of requests to hipchat and the fix has nothing to do with it, sorry for the noise

TonyLeeVT commented 7 years ago

I am having the same issue Ramona, so thank you for posting this question. How do you specify a room name that contains spaces (ex: test room)? I tried surrounding the room name with quotes and single quotes (ex: "test room"). It does not like either method and ends up creating a room called "test. I can specify the room using the full room name, xxxxx@conf.hipchat.com, but then receive the rate limiting error messages you mentioned above when joining more than 1 room. Thank you in advance.