本文整理汇总了Python中twisted.words.xish.domish.Element.attributes['id']方法的典型用法代码示例。如果您正苦于以下问题:Python Element.attributes['id']方法的具体用法?Python Element.attributes['id']怎么用?Python Element.attributes['id']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.words.xish.domish.Element
的用法示例。
在下文中一共展示了Element.attributes['id']方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showHelpAction
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def showHelpAction(self, el, sessionid=None):
to = el.getAttribute('from')
ID = el.getAttribute('id')
ulang = utils.getLang(el)
iq = Element((None, 'iq'))
iq.attributes['to'] = to
iq.attributes['from'] = config.jid
if ID:
iq.attributes['id'] = ID
iq.attributes['type'] = 'result'
command = iq.addElement('command')
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
command.attributes['node'] = 'help'
command.attributes['xmlns'] = globals.COMMANDS
command.attributes['status'] = 'executing'
actions = command.addElement('actions')
actions.attributes['execute'] = 'next'
actions.addElement('next')
x = command.addElement('x')
x.attributes['xmlns'] = 'jabber:x:data'
x.attributes['type'] = 'form'
title = x.addElement('title')
title.addContent(lang.get('command_Help'))
instructions = x.addElement('instructions')
instructions.addContent(lang.get('help_documentation'))
field = x.addElement('field')
field.attributes['var'] = 'help_action'
field.attributes['type'] = 'list-single'
field.attributes['label'] = lang.get('help_action')
desc = field.addElement('desc')
desc.addContent(lang.get('help_action_Desc'))
option = field.addElement('option')
option.attributes['label'] = help_mainroom
value = option.addElement('value')
value.addContent(help_mainroom)
if config.supportRoom:
option = field.addElement('option')
option.attributes['label'] = config.supportRoom
value = option.addElement('value')
value.addContent(config.supportRoom)
stage = x.addElement('field')
stage.attributes['type'] = 'hidden'
stage.attributes['var'] = 'stage'
value = stage.addElement('value')
value.addContent('2')
self.pytrans.send(iq)
示例2: sendCompletedForm
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendCompletedForm(self, el, sessionid=None):
to = el.getAttribute('from')
ID = el.getAttribute('id')
ulang = utils.getLang(el)
iq = Element((None, 'iq'))
iq.attributes = {'to': to, 'from': config.jid, 'type': 'result'}
if ID:
iq.attributes['id'] = ID
command = iq.addElement('command')
command.attributes = {
'node': 'settings',
'xmlns': globals.COMMANDS,
'status': 'completed'
}
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
note = command.addElement('note', None, lang.get('settings_changed'))
note.attributes['type'] = 'info'
x = command.addElement('x')
x.attributes = {'xmlns': 'jabber:x:data', 'type': 'form'}
x.addElement('title', None, lang.get('command_Settings'))
x.addElement('instructions', None, lang.get('settings_changed'))
self.pytrans.send(iq)
示例3: sendInvitation
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendInvitation(self, el, help_action, sessionid=None):
to = el.getAttribute('from')
ID = el.getAttribute('id')
ulang = utils.getLang(el)
message = Element((None, 'message'))
message.attributes['to'] = to
message.attributes['from'] = config.jid
if ID:
message.attributes['id'] = ID
x = message.addElement('x')
x.attributes['xmlns'] = 'jabber:x:conference'
x.attributes['jid'] = help_action
self.pytrans.send(message)
示例4: sendXStatusCompleted
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendXStatusCompleted(self, el, message, sessionid=None):
to = el.getAttribute('from')
ID = el.getAttribute('id')
ulang = utils.getLang(el)
iq = Element((None, 'iq'))
iq.attributes['to'] = to
iq.attributes['from'] = config.jid
if ID:
iq.attributes['id'] = ID
iq.attributes['type'] = 'result'
command = iq.addElement('command')
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
command.attributes['node'] = 'setxstatus'
command.attributes['xmlns'] = globals.COMMANDS
command.attributes['status'] = 'completed'
note = command.addElement('note')
note.attributes['type'] = 'info'
note.addContent(message)
x = command.addElement('x')
x.attributes['xmlns'] = 'jabber:x:data'
x.attributes['type'] = 'form'
title = x.addElement('title')
title.addContent(lang.get('command_SetXStatus'))
instructions = x.addElement('instructions')
instructions.addContent(message)
self.pytrans.send(iq)
示例5: sendSettingsClassForm
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendSettingsClassForm(self, el, sessionid=None):
to = el.getAttribute('from')
to_jid = internJID(to)
ID = el.getAttribute('id')
ulang = utils.getLang(el)
iq = Element((None, 'iq'))
iq.attributes = {'to': to, 'from': config.jid, 'type': 'result'}
if ID:
iq.attributes['id'] = ID
command = iq.addElement('command')
command.attributes = {
'node': 'settings',
'xmlns': globals.COMMANDS,
'status': 'executing'
}
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
actions = command.addElement('actions')
actions.attributes['execute'] = 'next'
actions.addElement('next')
x = command.addElement('x')
x.attributes = {'xmlns': 'jabber:x:data', 'type': 'form'}
x.addElement('title', None, lang.get('command_Settings'))
x.addElement('instructions', None, lang.get('settings_instructions'))
field = x.addElement('field')
field.attributes = {
'var': 'settings_page',
'type': 'list-single',
'label': lang.get('settings_category')
}
field.addElement('desc', None, lang.get('settings_instructions_Desc'))
option = field.addElement('option')
option.attributes['label'] = lang.get('settings_category_clist')
option.addElement('value', None, 'clist_settings')
option = field.addElement('option')
option.attributes['label'] = lang.get('settings_category_xstatus')
option.addElement('value', None, 'xstatus_settings')
option = field.addElement('option')
option.attributes['label'] = lang.get('settings_category_message')
option.addElement('value', None, 'message_settings')
option = field.addElement('option')
option.attributes['label'] = lang.get('settings_category_personal_events')
option.addElement('value', None, 'personal_events_settings')
option = field.addElement('option')
option.attributes['label'] = lang.get('settings_category_autoanswer')
option.addElement('value', None, 'autoanswer_settings')
stage = x.addElement('field')
stage.attributes = {'type': 'hidden', 'var': 'stage'}
stage.addElement('value', None, '1')
self.pytrans.send(iq)
示例6: sendAutoanswerSettingsForm
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendAutoanswerSettingsForm(self, el, sessionid=None):
to = el.getAttribute("from")
ID = el.getAttribute("id")
ulang = utils.getLang(el)
toj = internJID(to)
jid = toj.userhost()
bos = self.pytrans.sessions[jid].legacycon.bos
settings = bos.selfSettings
iq = Element((None, 'iq'))
iq.attributes = {'to': to, 'from': config.jid, 'type': 'result'}
if ID:
iq.attributes['id'] = ID
command = iq.addElement('command')
command.attributes = {
'node': 'settings',
'xmlns': globals.COMMANDS,
'status': 'executing'
}
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
actions = command.addElement("actions")
actions.attributes["execute"] = "complete"
actions.addElement('prev')
actions.addElement("complete")
x = command.addElement("x")
x.attributes = {'xmlns': 'jabber:x:data', 'type': 'form'}
title = x.addElement('title')
title.addContent(lang.get('settings_category_autoanswer'))
field = x.addElement('field')
field.attributes = {
'var': 'autoanswer_text',
'type': 'text-multi',
'label': lang.get('autoanswer_text')
}
value = field.addElement('value')
if 'autoanswer_text' in settings:
value.addContent(str(settings['autoanswer_text']))
else:
value.addContent(lang.get('autoanswer_text_content'))
field.addElement('desc', None, lang.get('autoanswer_text_Desc'))
field = x.addElement('field')
field.attributes = {
'var': 'autoanswer_enable',
'type': 'boolean',
'label': lang.get('autoanswer_enable')
}
field.addElement('value', None, str(settings['autoanswer_enable']))
field.addElement('desc', None, lang.get('autoanswer_enable_Desc'))
field = x.addElement('field')
field.attributes = {
'var': 'autoanswer_hide_dialog',
'type': 'boolean',
'label': lang.get('autoanswer_hide_dialog')
}
field.addElement('value', None, str(settings['autoanswer_hide_dialog']))
field.addElement('desc', None, lang.get('autoanswer_hide_dialog_Desc'))
field = x.addElement('field')
field.attributes = {'type': 'hidden', 'var': 'settings_page'}
field.addElement('value', None, 'autoanswer_settings')
stage = x.addElement('field')
stage.attributes = {'type': 'hidden', 'var': 'stage'}
stage.addElement('value', None, '2')
self.pytrans.send(iq)
示例7: sendPersonalEventsSettingsForm
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendPersonalEventsSettingsForm(self, el, sessionid=None):
to = el.getAttribute("from")
ID = el.getAttribute("id")
ulang = utils.getLang(el)
toj = internJID(to)
jid = toj.userhost()
bos = self.pytrans.sessions[jid].legacycon.bos
settings = bos.selfSettings
iq = Element((None, 'iq'))
iq.attributes = {'to': to, 'from': config.jid, 'type': 'result'}
if ID:
iq.attributes['id'] = ID
command = iq.addElement('command')
command.attributes = {
'node': 'settings',
'xmlns': globals.COMMANDS,
'status': 'executing'
}
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
actions = command.addElement("actions")
actions.attributes["execute"] = "complete"
actions.addElement('prev')
actions.addElement("complete")
x = command.addElement("x")
x.attributes = {'xmlns': 'jabber:x:data', 'type': 'form'}
x.addElement('title', None, lang.get('settings_category_personal_events'))
field = x.addElement('field')
field.attributes = {
'var': 'user_mood_receiving',
'type': 'boolean',
'label': lang.get('user_mood_receiving')
}
field.addElement('value', None, str(settings['user_mood_receiving']))
field.addElement('desc', None, lang.get('user_mood_receiving_Desc'))
field = x.addElement('field')
field.attributes = {
'var': 'user_activity_receiving',
'type': 'boolean',
'label': lang.get('user_activity_receiving')
}
field.addElement('value', None, str(settings['user_activity_receiving']))
field.addElement('desc', None, lang.get('user_activity_receiving_Desc'))
field = x.addElement('field')
field.attributes = {
'var': 'user_tune_receiving',
'type': 'boolean',
'label': lang.get('user_tune_receiving')
}
field.addElement('value', None, settings['user_tune_receiving'])
field.addElement('desc', None, lang.get('user_tune_receiving_Desc'))
field = x.addElement('field')
field.attributes = {'type': 'hidden', 'var': 'settings_page'}
field.addElement('value', None, 'personal_events_settings')
stage = x.addElement('field')
stage.attributes = {'type': 'hidden', 'var': 'stage'}
stage.addElement('value', None, '2')
self.pytrans.send(iq)
示例8: sendMessageSettingsForm
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendMessageSettingsForm(self, el, sessionid=None):
to = el.getAttribute("from")
ID = el.getAttribute("id")
ulang = utils.getLang(el)
toj = internJID(to)
jid = toj.userhost()
bos = self.pytrans.sessions[jid].legacycon.bos
settings = bos.selfSettings
iq = Element((None, 'iq'))
iq.attributes = {'to': to, 'from': config.jid, 'type': 'result'}
if ID:
iq.attributes['id'] = ID
command = iq.addElement('command')
command.attributes = {
'node': 'settings',
'xmlns': globals.COMMANDS,
'status': 'executing'
}
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
actions = command.addElement("actions")
actions.attributes["execute"] = "complete"
actions.addElement('prev')
actions.addElement("complete")
x = command.addElement('x')
x.attributes = {'xmlns': 'jabber:x:data', 'type': 'form'}
x.addElement('title', None, lang.get('settings_category_message'))
userencoding_list = {
'userencoding_list_western_iso': 'iso-8859-1',
'userencoding_list_western_win': 'cp1252',
'userencoding_list_ceuropean_iso': 'iso-8859-2',
'userencoding_list_ceuropean_win': 'cp1250',
'userencoding_list_seuropean_iso': 'iso-8859-3',
'userencoding_list_cyrillic_iso': 'iso-8859-5',
'userencoding_list_cyrillic_win': 'cp1251',
'userencoding_list_greek_iso': 'iso-8859-7',
'userencoding_list_greek_win': 'cp1253',
'userencoding_list_hebrew_iso': 'iso-8859-8',
'userencoding_list_hebrew_win': 'cp1255',
'userencoding_list_selected': 'selected'
}
field = x.addElement('field')
field.attributes = {
'var': 'userencoding_list',
'type': 'list-single',
'label': lang.get('userencoding_list')
}
for title in userencoding_list:
option = field.addElement('option')
option.attributes['label'] = lang.get(title)
option.addElement('value', None, str(userencoding_list[title]))
if str(settings['userencoding_list']) not in userencoding_list.values() and str(settings['userencoding_list']) != config.encoding: # encoding not from list
option = field.addElement('option')
option.attributes['label'] = '%s (%s)' % (lang.get('userencoding_list_other'), str(settings['userencoding_list']))
option.addElement('value', None, str(settings['userencoding_list']))
if config.encoding not in userencoding_list.values(): # encoding from config
option = field.addElement('option')
option.attributes['label'] = '%s (%s)' % (lang.get('userencoding_list_default'), config.encoding)
option.addElement('value', None, config.encoding)
field.addElement('value', None, str(settings['userencoding_list']))
field.addElement('desc', None, lang.get('userencoding_list_Desc'))
field = x.addElement('field')
field.attributes = {
'var': 'userencoding_other',
'type': 'text-single',
'label': lang.get('userencoding_other')
}
field.addElement('value', None, str(settings['userencoding_other']))
field.addElement('desc', None, lang.get('userencoding_other_Desc'))
utf8_messages_sendmode = {
'utf8_messages_sendmode_none': 0,
'utf8_messages_sendmode_as_reply': 1,
'utf8_messages_sendmode_always': 2
}
field = x.addElement('field')
field.attributes = {
'var': 'utf8_messages_sendmode',
'type': 'list-single',
'label': lang.get('utf8_messages_sendmode')
}
for title in utf8_messages_sendmode:
option = field.addElement('option')
option.attributes['label'] = lang.get(title)
option.addElement('value', None, str(utf8_messages_sendmode[title]))
field.addElement('value', None, str(settings['utf8_messages_sendmode']))
field.addElement('desc', None, lang.get('utf8_messages_sendmode_Desc'))
msgconfirm_sendmode = {
'msgconfirm_sendmode_none': 0,
'msgconfirm_sendmode_for_utf8': 1,
#.........这里部分代码省略.........
示例9: sendContactListSettingsForm
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendContactListSettingsForm(self, el, sessionid=None):
to = el.getAttribute("from")
ID = el.getAttribute("id")
ulang = utils.getLang(el)
toj = internJID(to)
jid = toj.userhost()
bos = self.pytrans.sessions[jid].legacycon.bos
settings = bos.selfSettings
iq = Element((None, 'iq'))
iq.attributes = {'to': to, 'from': config.jid, 'type': 'result'}
if ID:
iq.attributes['id'] = ID
command = iq.addElement('command')
command.attributes = {
'node': 'settings',
'xmlns': globals.COMMANDS,
'status': 'executing'
}
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
actions = command.addElement("actions")
actions.attributes["execute"] = "complete"
actions.addElement('prev')
actions.addElement("complete")
x = command.addElement("x")
x.attributes = {'xmlns': 'jabber:x:data', 'type': 'form'}
title = x.addElement('title')
title.addContent(lang.get('settings_category_clist'))
field = x.addElement('field')
field.attributes = {
'var': 'clist_show_phantombuddies',
'type': 'boolean',
'label': lang.get('settings_clist_show_phantombuddies') % bos.ssistats['phantombuddies']
}
field.addElement('value', None, str(settings['clist_show_phantombuddies']))
field.addElement('desc', None, lang.get('settings_clist_show_phantombuddies_Desc'))
field = x.addElement('field')
field.attributes = {
'var': 'clist_deny_all_auth_requests',
'type': 'boolean',
'label': lang.get('settings_clist_deny_all_auth_requests')
}
field.addElement('value', None, str(settings['clist_deny_all_auth_requests']))
field.addElement('desc', None, lang.get('settings_clist_deny_all_auth_requests_Desc'))
field = x.addElement('field')
field.attributes = {'type': 'hidden', 'var': 'settings_page'}
field.addElement('value', None, 'clist_settings')
stage = x.addElement('field')
stage.attributes = {'type': 'hidden', 'var': 'stage'}
stage.addElement('value', None, '2')
self.pytrans.send(iq)
示例10: sendXstatusSettingsForm
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendXstatusSettingsForm(self, el, sessionid=None):
to = el.getAttribute("from")
ID = el.getAttribute("id")
ulang = utils.getLang(el)
toj = internJID(to)
jid = toj.userhost()
settings = dict([])
bos = self.pytrans.sessions[jid].legacycon.bos
if config.xstatusessupport:
settings = bos.selfSettings
iq = Element((None, 'iq'))
iq.attributes = {'to': to, 'from': config.jid, 'type': 'result'}
if ID:
iq.attributes['id'] = ID
command = iq.addElement('command')
command.attributes = {
'node': 'settings',
'xmlns': globals.COMMANDS,
'status': 'executing'
}
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
actions = command.addElement("actions")
actions.attributes["execute"] = "complete"
actions.addElement('prev')
actions.addElement("complete")
x = command.addElement("x")
x.attributes = {'xmlns': 'jabber:x:data', 'type': 'form'}
x.addElement('title', None, lang.get('settings_category_xstatus'))
if config.xstatusessupport:
field = x.addElement('field')
field.attributes = {
'var': 'away_messages_sending',
'type': 'boolean',
'label': lang.get('away_messages_sending')
}
field.addElement('value', None, str(settings['away_messages_sending']))
field.addElement('desc', None, lang.get('away_messages_sending_Desc'))
field = x.addElement('field')
field.attributes = {
'var': 'away_messages_receiving',
'type': 'boolean',
'label': lang.get('away_messages_receiving')
}
field.addElement('value', None, str(settings['away_messages_receiving']))
field.addElement('desc', None, lang.get('away_messages_receiving_Desc'))
xstatus_sending = {
'xstatus_sendmode_none': 0,
'xstatus_sendmode_ICQ5': 1,
'xstatus_sendmode_ICQ6': 2,
'xstatus_sendmode_ICQ5_6': 3
}
field = x.addElement('field')
field.attributes = {
'var': 'xstatus_sending_mode',
'type': 'list-single',
'label': lang.get('xstatus_sendmode')
}
for title in xstatus_sending:
option = field.addElement('option')
option.attributes['label'] = lang.get(title)
option.addElement('value', None, str(xstatus_sending[title]))
field.addElement('value', None, str(settings['xstatus_sending_mode']))
field.addElement('desc', None, lang.get('xstatus_sendmode_Desc'))
field = x.addElement('field')
field.attributes = {
'var': 'xstatus_saving_enabled',
'type': 'boolean',
'label': lang.get('xstatus_restore_after_disconnect')
}
field.addElement('value', None, str(settings['xstatus_saving_enabled']))
field.addElement('desc', None, lang.get('xstatus_restore_after_disconnect_Desc'))
xstatus_receiving = {
'xstatus_recvmode_none': 0,
'xstatus_recvmode_ICQ5': 1,
'xstatus_recvmode_ICQ6': 2,
'xstatus_recvmode_ICQ5_6': 3
}
field = x.addElement('field')
field.attributes = {
'var': 'xstatus_receiving_mode',
'type': 'list-single',
'label': lang.get('xstatus_recvmode')
}
for title in xstatus_receiving:
option = field.addElement('option')
option.attributes['label'] = lang.get(title)
option.addElement('value', None, str(xstatus_receiving[title]))
#.........这里部分代码省略.........
示例11: sendXStatusNameSelectionForm
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendXStatusNameSelectionForm(self, el, sessionid=None):
to = el.getAttribute('from')
to_jid = internJID(to)
jid = to_jid.userhost()
ID = el.getAttribute('id')
ulang = utils.getLang(el)
iq = Element((None, 'iq'))
iq.attributes['to'] = to
iq.attributes['from'] = config.jid
if ID:
iq.attributes['id'] = ID
iq.attributes['type'] = 'result'
command = iq.addElement('command')
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
command.attributes['node'] = 'setxstatus'
command.attributes['xmlns'] = globals.COMMANDS
command.attributes['status'] = 'executing'
actions = command.addElement('actions')
actions.attributes['execute'] = 'next'
actions.addElement('next')
x = command.addElement('x')
x.attributes['xmlns'] = 'jabber:x:data'
x.attributes['type'] = 'form'
title = x.addElement('title')
title.addContent(lang.get('xstatus_set_xstatus_name'))
instructions = x.addElement('instructions')
instructions.addContent(lang.get('xstatus_set_instructions'))
field = x.addElement('field')
field.attributes['var'] = 'xstatus_name'
field.attributes['type'] = 'list-single'
field.attributes['label'] = lang.get('xstatus_name')
desc = field.addElement('desc')
desc.addContent(lang.get('xstatus_set_instructions_Desc'))
option = field.addElement('option')
option.attributes['label'] = lang.get('xstatus_no_xstatus')
value = option.addElement('value')
value.addContent('None')
counter = 0
limit = False
if int(self.pytrans.sessions[jid].legacycon.bos.settingsOptionValue('xstatus_sending_mode')) == 2:
limit = True
counter = 24
for xstatus_title in oscar.X_STATUS_NAME:
if limit:
if counter > 0:
option = field.addElement('option')
option.attributes['label'] = lang.get(xstatus_title)
value = option.addElement('value')
value.addContent(xstatus_title)
counter -= 1
else:
option = field.addElement('option')
option.attributes['label'] = lang.get(xstatus_title)
value = option.addElement('value')
value.addContent(xstatus_title)
value = field.addElement('value')
current_xstatus_name = self.pytrans.sessions[jid].legacycon.bos.getSelfXstatusName()
if current_xstatus_name != '':
value.addContent(current_xstatus_name)
else:
value.addContent('None')
stage = x.addElement('field')
stage.attributes['type'] = 'hidden'
stage.attributes['var'] = 'stage'
value = stage.addElement('value')
value.addContent('1')
self.pytrans.send(iq)
示例12: sendXStatusTextSelectionForm
# 需要导入模块: from twisted.words.xish.domish import Element [as 别名]
# 或者: from twisted.words.xish.domish.Element import attributes['id'] [as 别名]
def sendXStatusTextSelectionForm(self, el, xstatus_name, sessionid=None):
to = el.getAttribute('from')
ID = el.getAttribute('id')
ulang = utils.getLang(el)
iq = Element((None, 'iq'))
iq.attributes['to'] = to
iq.attributes['from'] = config.jid
if ID:
iq.attributes['id'] = ID
iq.attributes['type'] = 'result'
command = iq.addElement('command')
if sessionid:
command.attributes['sessionid'] = sessionid
else:
command.attributes['sessionid'] = self.pytrans.makeMessageID()
command.attributes['node'] = 'setxstatus'
command.attributes['xmlns'] = globals.COMMANDS
command.attributes['status'] = 'executing'
actions = command.addElement('actions')
actions.attributes['execute'] = 'complete'
actions.addElement('prev')
actions.addElement('complete')
x = command.addElement('x')
x.attributes['xmlns'] = 'jabber:x:data'
x.attributes['type'] = 'form'
title = x.addElement('title')
title.addContent(lang.get('xstatus_set_details'))
toj = internJID(to)
jid = toj.userhost()
xstatus_number = self.pytrans.sessions[jid].legacycon.bos.getXstatusNumberByName(xstatus_name)
title, desc = self.pytrans.xdb.getXstatusText(jid, xstatus_number)
if title == '':
title = lang.get(xstatus_name)
else:
if config.xdbDriver == 'xmlfiles': # fix problem with & character
title = utils.fixCharactersInDeXML(title)
xstatus_title = x.addElement('field')
xstatus_title.attributes['type'] = 'text-single'
xstatus_title.attributes['var'] = 'xstatus_title'
xstatus_title.attributes['label'] = lang.get('xstatus_title')
value = xstatus_title.addElement('value')
value.addContent(title)
xstatus_desc = x.addElement('field')
xstatus_desc.attributes['type'] = 'text-multi'
xstatus_desc.attributes['var'] = 'xstatus_desc'
xstatus_desc.attributes['label'] = lang.get('xstatus_description')
value = xstatus_desc.addElement('value')
value.addContent(desc)
xstatus_icon = x.addElement('field')
xstatus_icon.attributes['type'] = 'hidden'
xstatus_icon.attributes['var'] = 'xstatus_name'
value = xstatus_icon.addElement('value')
value.addContent(xstatus_name)
stage = x.addElement('field')
stage.attributes['type'] = 'hidden'
stage.attributes['var'] = 'stage'
value = stage.addElement('value')
value.addContent('2')
self.pytrans.send(iq)