bots = []
for bot_el in config.getElementsByTagName('bot'):
	debug = False
	if bot_el.hasAttribute('debug'):
		if bot_el.getAttribute('debug') == 'true':
			debug = True
	
	admins = []
	for admin_el in bot_el.getElementsByTagName('admin'):
		if admin_el.hasAttribute('jid'):
			admin = Admin()
			admin.jid = admin_el.getAttribute('jid')
			if admin_el.hasAttribute('say_level'):
				admin.say_level = say_levels.get(admin_el.getAttribute('say_level'))
			else:
				admin.say_level = say_levels.warning
			admins.append(admin)
	
	bot = Bot(bot_el.getAttribute('jid'), bot_el.getAttribute('password'), bot_el.getAttribute('nickname'), admins=admins, debug=debug)
	bots.append(bot)
	for bridge_el in bot_el.getElementsByTagName('bridge'):
		xmpp_room = bridge_el.getElementsByTagName('xmpp-room')[0]
		irc = bridge_el.getElementsByTagName('irc')[0]
		
		irc_connection_interval = 1
		if irc.hasAttribute('connection_interval'):
			try:
				irc_connection_interval = float(irc.getAttribute('connection_interval'))
			except ValueError:
示例#2
0
 def format_message(self, importance, message):
     if importance < 0 or importance >= len(say_levels.levels):
         raise Exception('[Internal Error] unknown message importance')
     return '[' + str(say_levels.get(importance)) + '] ' + message
示例#3
0
    bots_jids.append(bot_el.getAttribute('jid'))

bots = []
for bot_el in config.getElementsByTagName('bot'):
    debug = False
    if bot_el.hasAttribute('debug'):
        if bot_el.getAttribute('debug') == 'true':
            debug = True

    admins = []
    for admin_el in bot_el.getElementsByTagName('admin'):
        if admin_el.hasAttribute('jid'):
            admin = Admin()
            admin.jid = admin_el.getAttribute('jid')
            if admin_el.hasAttribute('say_level'):
                admin.say_level = say_levels.get(
                    admin_el.getAttribute('say_level'))
            else:
                admin.say_level = say_levels.warning
            admins.append(admin)

    bot = Bot(bot_el.getAttribute('jid'),
              bot_el.getAttribute('password'),
              bot_el.getAttribute('nickname'),
              admins=admins,
              debug=debug)
    bots.append(bot)
    for bridge_el in bot_el.getElementsByTagName('bridge'):
        xmpp_room = bridge_el.getElementsByTagName('xmpp-room')[0]
        irc = bridge_el.getElementsByTagName('irc')[0]

        irc_connection_interval = 1
示例#4
0
文件: bot.py 项目: Changaco/xib
	def format_message(self, importance, message):
		if importance < 0 or importance >= len(say_levels.levels):
			raise Exception('[Internal Error] unknown message importance')
		return'['+str(say_levels.get(importance))+'] '+message