在HipChat

时间:2017-08-30 18:19:04

标签: python errbot

我试图将Errbot与HipChat服务器(不是云)一起使用。看起来Errbot在房间名称和它的xmpp jid之间感到困惑。例如,使用名为BotTest的房间进行测试,该房间的jid为1_bottest@conf.btf.hipchat.com

  • 当我将CHATROOM_PRESENCE设置为房间名称并在该房间发送任何消息时,Errbot会因错误"Room '1_bottest@conf.btf.hipchat.com' not found"而崩溃。
  • 当我将它设置为房间的jid时,Errbot创建了一个与jid同名的新房间和一个'1_1_bottestconf.btf.hipchat.com@conf.btf.hipchat.com'的jid。然后,当我在新房间发送消息时,它会因错误"Room '1_1_bottestconf.btf.hipchat.com@conf.btf.hipchat.com' not found".
  • 而崩溃

我的config.py如下:

import logging
BACKEND = 'XMPP'  # defaults to XMPP
BOT_DATA_DIR = r'/auto/home.nas03/eeshel/work/errbot/data'
BOT_EXTRA_PLUGIN_DIR = '/auto/home.nas03/eeshel/work/errbot/plugins'
BOT_LOG_FILE = r'/auto/home.nas03/eeshel/work/errbot/errbot.log'
BOT_LOG_LEVEL = logging.DEBUG
TEXT_COLOR_THEME = 'dark'
BOT_ADMINS = ('1_8@chat.btf.hipchat.com', )
BOT_PREFIX = '\\'
BOT_ALT_PREFIXES = ('Hermes',)
BOT_ALT_PREFIX_SEPARATORS = (':', ',', ';')
BOT_ALT_PREFIX_CASEINSENSITIVE = True
CHATROOM_FN = 'Hermes the Bot'
CHATROOM_PRESENCE = ('1_bottest@conf.btf.hipchat.com',)
BOT_IDENTITY = {
    'username' : '1_2@hipchat.eng.<ourdomain>',
    'password' : '*****',
    'token'    : '*****',
    'endpoint' : '10.18.0.185',
}
XMPP_KEEPALIVE_INTERVAL = 60
XMPP_USE_IPV6 = False
XMPP_CA_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt"

2 个答案:

答案 0 :(得分:0)

您可以参考下面的链接,它可以帮助您http://errbot.io/en/latest/user_guide/configuration/hipchat.html

答案 1 :(得分:0)

尽管documentation非常好,但我也很难使这些事情正确无误。完成后,重新阅读该文档是有道理的,但事后看来是20/20!

这是一个示例配置部分,可让您的errbot连接到Hipchat:

# Assuming you are @jdoe in your Hipchat and you want admin privs for your bot
BOT_ADMINS = ('@jdoe', '@mmouse', )

# Let's assume your bot's Hipchat account is "superbot" with
# full name of "Super Bot"
BACKEND = 'Hipchat'
if BACKEND == 'Hipchat':
    # http://errbot.io/en/latest/user_guide/configuration/hipchat.html
    BOT_IDENTITY = {
        # You get username by logging into Hipchat with the account, then go to
        # Profile / XMPP/Jabber Info and find the "Jabber ID"
        'username': '123456_1234567@chat.hipchat.com',

        # Simply the password of the Hipchat account
        'password': 'password12345',

        # You get token by logging into Hipchat with the account, then go to
        # Profile / API Access and generate an API token--assigning it all
        # scopes unless you know otherwise.
        'token': 'azwx2BdVzGz0riEjqybWinLbUkBSIz6rpsa259HE',

        ## If you're using HipChat server (self-hosted HipChat) then you should set
        ## the endpoint below. If you don't use HipChat server but use the hosted version
        ## of HipChat then you may leave this commented out.
        #'endpoint': 'https://api.hipchat.com'
    }

    CHATROOM_FN = 'Super Bot'
    BOT_ALT_PREFIXES = ('@superbot', '@SuperBot', '@stinkfinger',)
    # To "listen" for any mentions of @superbot:
    CHATROOM_PRESENCE = ()
    # To also join rooms to listen to all messages in those rooms,
    # do this instead:
    #CHATROOM_PRESENCE = ('Room 1', 'Lounge',)

重要的是还要注意,我必须降级这些软件包才能使Hipchat集成正常工作。我在我的requirements.txt中做了这些更改:

pyasn1==0.3.7
pyasn1-modules==0.1.5
sleekxmpp==1.3.2