Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ENH: Add a DND mode -- turned on and off using ,dnd.

  • Loading branch information...
commit b9d93d027a83a632f0d5d3f683f0fcefc13bcf08 1 parent 3026dde
@punchagan authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 chatroom.py
View
20 chatroom.py
@@ -347,6 +347,26 @@ def unsubscribe( self, mess, args):
self.save_state()
return 'You are now unsubscribed.'
+ @botcmd(name=',dnd')
+ def dnd( self, mess, args):
+ """Switch to do-not-disturb mode. Use ,dnd to switch back."""
+ user = self.get_sender_username(mess)
+ if user not in self.users and user not in self.invited:
+ return 'You are not subscribed!'
+ elif user in self.users:
+ name = self.users.pop(user)
+ self.invited[user] = name
+ self.message_queue.append('_%s turned on DND_' % name)
+ self.log.info( '%s turned on DND.' % name)
+ self.save_state()
+ return 'DND turned on.'
+ elif user in self.invited:
+ name = self.invited.pop(user)
+ self.users[user] = name
+ self.message_queue.append('_%s turned off DND_' % name)
+ self.log.info( '%s turned off DND.' % name)
+ self.save_state()
+ return 'DND turned off.'
@botcmd(name=',alias')
def alias( self, mess, args):
Please sign in to comment.
Something went wrong with that request. Please try again.