Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0045.py @ 1371:876c9fbd0b3d
plugin text command, XEP-0045, XEP-0048, XEP-0249: removed feedBackWrongContext which is no more usefull with new _contextValid method
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 19 Mar 2015 14:30:08 +0100 |
parents | bf3f669a6052 |
children | 0d12d4e32664 |
comparison
equal
deleted
inserted
replaced
1370:53c7678c27a6 | 1371:876c9fbd0b3d |
---|---|
446 return self.clients[profile].modifyAffiliationList(room_jid, [entity_jid], options['affiliation']) | 446 return self.clients[profile].modifyAffiliationList(room_jid, [entity_jid], options['affiliation']) |
447 | 447 |
448 # Text commands # | 448 # Text commands # |
449 | 449 |
450 def cmd_nick(self, mess_data, profile): | 450 def cmd_nick(self, mess_data, profile): |
451 """change nickname""" | 451 """change nickname |
452 log.debug("Catched nick command") | 452 |
453 | 453 @command (group): new_nick |
454 if mess_data['type'] != "groupchat": | 454 - new_nick: new nick to use |
455 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('nick', 'groupchat', mess_data, profile) | 455 """ |
456 return False | |
457 | |
458 nick = mess_data["unparsed"].strip() | 456 nick = mess_data["unparsed"].strip() |
459 room = mess_data["to"] | 457 if nick: |
460 | 458 room = mess_data["to"] |
461 self.nick(room, nick, profile) | 459 self.nick(room, nick, profile) |
462 | 460 |
463 return False | 461 return False |
464 | 462 |
465 def cmd_join(self, mess_data, profile): | 463 def cmd_join(self, mess_data, profile): |
466 """join a new room (on the same service if full jid is not specified)""" | 464 """join a new room |
467 log.debug("Catched join command") | 465 |
468 | 466 @command (group): JID |
469 if mess_data['type'] != "groupchat": | 467 - JID: room to join (on the same service if full jid is not specified) |
470 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('join', 'groupchat', mess_data, profile) | 468 """ |
471 return False | |
472 | |
473 if mess_data["unparsed"].strip(): | 469 if mess_data["unparsed"].strip(): |
474 room_jid = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) | 470 room_jid = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) |
475 nick = (self.getRoomNick(room_jid, profile) or | 471 nick = (self.getRoomNick(room_jid, profile) or |
476 self.host.getClient(profile).jid.user) | 472 self.host.getClient(profile).jid.user) |
477 self.join(room_jid, nick, {}, profile) | 473 self.join(room_jid, nick, {}, profile) |
478 | 474 |
479 return False | 475 return False |
480 | 476 |
481 def cmd_leave(self, mess_data, profile): | 477 def cmd_leave(self, mess_data, profile): |
482 """quit a room""" | 478 """quit a room |
483 log.debug("Catched leave command") | 479 |
484 | 480 @command (group): [ROOM_JID] |
485 if mess_data['type'] != "groupchat": | 481 - ROOM_JID: jid of the room to live (current room if not specified) |
486 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('leave', 'groupchat', mess_data, profile) | 482 """ |
487 return False | |
488 | |
489 if mess_data["unparsed"].strip(): | 483 if mess_data["unparsed"].strip(): |
490 room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) | 484 room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) |
491 else: | 485 else: |
492 room = mess_data["to"] | 486 room = mess_data["to"] |
493 | 487 |
494 self.leave(room, profile) | 488 self.leave(room, profile) |
495 | 489 |
496 return False | 490 return False |
497 | 491 |
498 def cmd_part(self, mess_data, profile): | 492 def cmd_part(self, mess_data, profile): |
499 """just a synonym of /leave""" | 493 """just a synonym of /leave |
494 | |
495 @command (group): [ROOM_JID] | |
496 - ROOM_JID: jid of the room to live (current room if not specified) | |
497 """ | |
500 return self.cmd_leave(mess_data, profile) | 498 return self.cmd_leave(mess_data, profile) |
501 | 499 |
502 def cmd_kick(self, mess_data, profile): | 500 def cmd_kick(self, mess_data, profile): |
503 """kick a room member | 501 """kick a room member |
504 | 502 |
505 @command (group): (nick) | 503 @command (group): ROOM_NICK |
506 - nick: the nick of the person to kick | 504 - ROOM_NICK: the nick of the person to kick |
507 """ | 505 """ |
508 log.debug("Catched kick command") | |
509 | |
510 if mess_data['type'] != "groupchat": | |
511 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('kick', 'groupchat', mess_data, profile) | |
512 return False | |
513 | |
514 options = mess_data["unparsed"].strip().split() | 506 options = mess_data["unparsed"].strip().split() |
515 try: | 507 try: |
516 nick = options[0] | 508 nick = options[0] |
517 assert(self.isNickInRoom(mess_data["to"], nick, profile)) | 509 assert(self.isNickInRoom(mess_data["to"], nick, profile)) |
518 except (IndexError, AssertionError): | 510 except (IndexError, AssertionError): |
535 | 527 |
536 @command (group): (JID) [reason] | 528 @command (group): (JID) [reason] |
537 - JID: the JID of the entity to ban | 529 - JID: the JID of the entity to ban |
538 - reason: the reason why this entity is being banned | 530 - reason: the reason why this entity is being banned |
539 """ | 531 """ |
540 log.debug("Catched ban command") | |
541 | |
542 if mess_data['type'] != "groupchat": | |
543 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('ban', 'groupchat', mess_data, profile) | |
544 return False | |
545 | |
546 options = mess_data["unparsed"].strip().split() | 532 options = mess_data["unparsed"].strip().split() |
547 try: | 533 try: |
548 jid_s = options[0] | 534 jid_s = options[0] |
549 entity_jid = jid.JID(jid_s).userhostJID() | 535 entity_jid = jid.JID(jid_s).userhostJID() |
550 assert(entity_jid.user) | 536 assert(entity_jid.user) |
573 - admin: grant admin privileges | 559 - admin: grant admin privileges |
574 - member: grant member privileges | 560 - member: grant member privileges |
575 - none: reset entity privileges | 561 - none: reset entity privileges |
576 - outcast: ban entity | 562 - outcast: ban entity |
577 """ | 563 """ |
578 log.debug("Catched affiliate command") | |
579 | |
580 if mess_data['type'] != "groupchat": | |
581 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('affiliate', 'groupchat', mess_data, profile) | |
582 return False | |
583 | |
584 options = mess_data["unparsed"].strip().split() | 564 options = mess_data["unparsed"].strip().split() |
585 try: | 565 try: |
586 jid_s = options[0] | 566 jid_s = options[0] |
587 entity_jid = jid.JID(jid_s).userhostJID() | 567 entity_jid = jid.JID(jid_s).userhostJID() |
588 assert(entity_jid.user) | 568 assert(entity_jid.user) |
605 return True | 585 return True |
606 d.addCallback(cb) | 586 d.addCallback(cb) |
607 return d | 587 return d |
608 | 588 |
609 def cmd_title(self, mess_data, profile): | 589 def cmd_title(self, mess_data, profile): |
610 """change room's subject""" | 590 """change room's subject |
611 log.debug("Catched title command") | 591 |
612 | 592 @command (group): title |
613 if mess_data['type'] != "groupchat": | 593 - title: new room subject |
614 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('title', 'groupchat', mess_data, profile) | 594 """ |
615 return False | |
616 | |
617 subject = mess_data["unparsed"].strip() | 595 subject = mess_data["unparsed"].strip() |
618 | 596 |
619 if subject: | 597 if subject: |
620 room = mess_data["to"] | 598 room = mess_data["to"] |
621 self.subject(room, subject, profile) | 599 self.subject(room, subject, profile) |
622 | 600 |
623 return False | 601 return False |
624 | 602 |
625 def cmd_topic(self, mess_data, profile): | 603 def cmd_topic(self, mess_data, profile): |
626 """just a synonym of /title""" | 604 """just a synonym of /title |
605 | |
606 @command (group): title | |
607 - title: new room subject | |
608 """ | |
627 return self.cmd_title(mess_data, profile) | 609 return self.cmd_title(mess_data, profile) |
628 | 610 |
629 def _whois(self, whois_msg, mess_data, target_jid, profile): | 611 def _whois(self, whois_msg, mess_data, target_jid, profile): |
630 """ Add MUC user information to whois """ | 612 """ Add MUC user information to whois """ |
631 if mess_data['type'] != "groupchat": | 613 if mess_data['type'] != "groupchat": |