Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0045.py @ 1002:291eb8216f6e
plugins TEXT-COMMANDS, XEP-0045, XEP-0048, XEP-0249:
- give a feedback instead of sending the message when the command is invalid or used in a wrong context
- add command /join for XEP-0249
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 30 Apr 2014 16:34:09 +0200 |
parents | 301b342c697a |
children | a7d33c7a8277 |
comparison
equal
deleted
inserted
replaced
1001:eb3601ff73bc | 1002:291eb8216f6e |
---|---|
377 def cmd_nick(self, mess_data, profile): | 377 def cmd_nick(self, mess_data, profile): |
378 """change nickname""" | 378 """change nickname""" |
379 log.debug("Catched nick command") | 379 log.debug("Catched nick command") |
380 | 380 |
381 if mess_data['type'] != "groupchat": | 381 if mess_data['type'] != "groupchat": |
382 #/nick command does nothing if we are not on a group chat | 382 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('nick', 'groupchat', mess_data, profile) |
383 log.info("Ignoring /nick command on a non groupchat message") | 383 return False |
384 | |
385 return True | |
386 | 384 |
387 nick = mess_data["unparsed"].strip() | 385 nick = mess_data["unparsed"].strip() |
388 room = mess_data["to"] | 386 room = mess_data["to"] |
389 | 387 |
390 self.nick(room, nick, profile) | 388 self.nick(room, nick, profile) |
394 def cmd_join(self, mess_data, profile): | 392 def cmd_join(self, mess_data, profile): |
395 """join a new room (on the same service if full jid is not specified)""" | 393 """join a new room (on the same service if full jid is not specified)""" |
396 log.debug("Catched join command") | 394 log.debug("Catched join command") |
397 | 395 |
398 if mess_data['type'] != "groupchat": | 396 if mess_data['type'] != "groupchat": |
399 #/leave command does nothing if we are not on a group chat | 397 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('join', 'groupchat', mess_data, profile) |
400 log.info("Ignoring /join command on a non groupchat message") | 398 return False |
401 return True | |
402 | 399 |
403 if mess_data["unparsed"].strip(): | 400 if mess_data["unparsed"].strip(): |
404 room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) | 401 room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) |
405 nick = (self.getRoomNick(mess_data["to"].userhost(), profile) or | 402 nick = (self.getRoomNick(mess_data["to"].userhost(), profile) or |
406 self.host.getClient(profile).jid.user) | 403 self.host.getClient(profile).jid.user) |
411 def cmd_leave(self, mess_data, profile): | 408 def cmd_leave(self, mess_data, profile): |
412 """quit a room""" | 409 """quit a room""" |
413 log.debug("Catched leave command") | 410 log.debug("Catched leave command") |
414 | 411 |
415 if mess_data['type'] != "groupchat": | 412 if mess_data['type'] != "groupchat": |
416 #/leave command does nothing if we are not on a group chat | 413 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('leave', 'groupchat', mess_data, profile) |
417 log.info("Ignoring /leave command on a non groupchat message") | 414 return False |
418 return True | |
419 | 415 |
420 if mess_data["unparsed"].strip(): | 416 if mess_data["unparsed"].strip(): |
421 room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) | 417 room = self.host.plugins[C.TEXT_CMDS].getRoomJID(mess_data["unparsed"].strip(), mess_data["to"].host) |
422 else: | 418 else: |
423 room = mess_data["to"] | 419 room = mess_data["to"] |
433 def cmd_title(self, mess_data, profile): | 429 def cmd_title(self, mess_data, profile): |
434 """change room's subject""" | 430 """change room's subject""" |
435 log.debug("Catched title command") | 431 log.debug("Catched title command") |
436 | 432 |
437 if mess_data['type'] != "groupchat": | 433 if mess_data['type'] != "groupchat": |
438 #/leave command does nothing if we are not on a group chat | 434 self.host.plugins[C.TEXT_CMDS].feedBackWrongContext('title', 'groupchat', mess_data, profile) |
439 log.info("Ignoring /title command on a non groupchat message") | 435 return False |
440 return True | |
441 | 436 |
442 subject = mess_data["unparsed"].strip() | 437 subject = mess_data["unparsed"].strip() |
443 | 438 |
444 if subject: | 439 if subject: |
445 room = mess_data["to"] | 440 room = mess_data["to"] |