Created
February 7, 2015 04:31
-
-
Save endofline/6b73591b69557ddc514d to your computer and use it in GitHub Desktop.
pseudo-python for iterating through a list of conversation memories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
searchfor = "some_string" | |
theconvid = None | |
if bot.memory.exists(["conv_data"]): # verify key exists | |
conv_list = bot.memory.get_by_path(["conv_data"]) # grab all conversations | |
for conv_id in conv_list: | |
conv_data = conv_list[conv_id] | |
if "shortname" in conv_data: # verify subkey exists | |
if searchfor in conv_data["shortname"]: # do text search | |
theconvid = conv_id | |
break # get out of the loop if we find it | |
if theconvid is not None: | |
print("i found {} in conversation {}".format(searchfor, theconvid)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment