embedded bots: Add StateHandler remove() function.

This commit is contained in:
derAnfaenger
2017-10-26 16:02:35 +02:00
committed by Tim Abbott
parent 3d7fb4888b
commit 17949adf11
3 changed files with 21 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ import re
import importlib
from zerver.lib.actions import internal_send_message
from zerver.models import UserProfile, \
get_bot_state, set_bot_state, get_bot_state_size, is_key_in_bot_state
get_bot_state, set_bot_state, get_bot_state_size, is_key_in_bot_state, remove_bot_state
from zerver.lib.integrations import EMBEDDED_BOTS
from six.moves import configparser
@@ -67,6 +67,10 @@ class StateHandler(object):
"should be str.".format(type(marshaled_value)))
set_bot_state(self.user_profile, key, marshaled_value)
def remove(self, key):
# type: (Text) -> None
remove_bot_state(self.user_profile, key)
def contains(self, key):
# type: (Text) -> bool
return is_key_in_bot_state(self.user_profile, key)