comparison jabberbot/xmppbot.py @ 2661:9f6e830c82e0

Add more fields to search form, fix bug left from changes in service discovery.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Wed, 08 Aug 2007 21:44:41 +0200
parents 892055d122fb
children 9c71c7c7f5f6
comparison
equal deleted inserted replaced
2659:892055d122fb 2661:9f6e830c82e0
440 help_form = _("Submit this form to perform a wiki search").encode("utf-8") 440 help_form = _("Submit this form to perform a wiki search").encode("utf-8")
441 search_type1 = _("Title search") 441 search_type1 = _("Title search")
442 search_type2 = _("Full-text search") 442 search_type2 = _("Full-text search")
443 search_label = _("Search type") 443 search_label = _("Search type")
444 search_label2 = _("Search text") 444 search_label2 = _("Search text")
445 case_label = _("Case-sensitive search")
446 regexp_label = _("Treat terms as regular expressions")
445 forms_warn = _("If you see this, your client probably doesn't support Data Forms.") 447 forms_warn = _("If you see this, your client probably doesn't support Data Forms.")
446 448
447 title_search = forms.Option("t", search_type1) 449 title_search = forms.Option("t", search_type1)
448 full_search = forms.Option("f", search_type2) 450 full_search = forms.Option("f", search_type2)
449 451
450 form = forms.Form(xmlnode_or_type="form", title=form_title, instructions=help_form) 452 form = forms.Form(xmlnode_or_type="form", title=form_title, instructions=help_form)
453 form.add_field(name="case", field_type="boolean", label=case_label)
454 form.add_field(name="regexp", field_type="boolean", label=regexp_label)
451 form.add_field(name="search_type", options=[title_search, full_search], field_type="list-single", label=search_label) 455 form.add_field(name="search_type", options=[title_search, full_search], field_type="list-single", label=search_label)
452 form.add_field(name="search", field_type="text-single", label=search_label2) 456 form.add_field(name="search", field_type="text-single", label=search_label2)
453 457
454 message = Message(to_jid=jid, body=forms_warn, subject=_("Wiki search")) 458 message = Message(to_jid=jid, body=forms_warn, subject=_("Wiki search"))
455 message.add_content(form) 459 message.add_content(form)
529 jid = sender.bare().as_utf8() 533 jid = sender.bare().as_utf8()
530 resource = sender.resource 534 resource = sender.resource
531 535
532 # Assume that outsiders know what they are doing. Clients that don't support 536 # Assume that outsiders know what they are doing. Clients that don't support
533 # data forms should display a warning passed in message <body>. 537 # data forms should display a warning passed in message <body>.
534 if jid not in self.contacts or self.contacts[jid].supports_forms(resource): 538 if jid not in self.contacts or self.contacts[jid].supports(resource, u"jabber:x:data"):
535 self.send_search_form(sender) 539 self.send_search_form(sender)
536 else: 540 else:
537 msg = {'text': _("This command requires a client supporting Data Forms.")} 541 msg = {'text': _("This command requires a client supporting Data Forms.")}
538 self.send_message(sender, msg, u"") 542 self.send_message(sender, msg, u"")
539 else: 543 else: