| @@ 18-35 (lines=18) @@ | ||
| 15 | lastDateGreeted = None |
|
| 16 | ||
| 17 | ||
| 18 | def getString(key, key1=None): |
|
| 19 | """ |
|
| 20 | Get a string from the string database. |
|
| 21 | """ |
|
| 22 | data = STRINGS[key] |
|
| 23 | if isinstance(data, list): |
|
| 24 | res = data[random.randint(0, len(data) - 1)] |
|
| 25 | elif isinstance(data, dict): |
|
| 26 | if key1 is None: |
|
| 27 | res = data |
|
| 28 | else: |
|
| 29 | res = data[key1] |
|
| 30 | if isinstance(res, list): |
|
| 31 | res = res[random.randint(0, len(res) - 1)] |
|
| 32 | elif isinstance(data, str): |
|
| 33 | res = data |
|
| 34 | ||
| 35 | return res |
|
| 36 | ||
| 37 | ||
| 38 | def getAllGeneralActions(): |
|
| @@ 55-72 (lines=18) @@ | ||
| 52 | STRINGS = json.load(f) |
|
| 53 | ||
| 54 | ||
| 55 | def getString(key, key1=None): |
|
| 56 | """ |
|
| 57 | Get a string from the string database. |
|
| 58 | """ |
|
| 59 | data = STRINGS[key] |
|
| 60 | if isinstance(data, list): |
|
| 61 | res = data[random.randint(0, len(data) - 1)] |
|
| 62 | elif isinstance(data, dict): |
|
| 63 | if key1 is None: |
|
| 64 | res = data |
|
| 65 | else: |
|
| 66 | res = data[key1] |
|
| 67 | if isinstance(res, list): |
|
| 68 | res = res[random.randint(0, len(res) - 1)] |
|
| 69 | elif isinstance(data, str): |
|
| 70 | res = data |
|
| 71 | ||
| 72 | return res |
|
| 73 | ||
| 74 | ||
| 75 | def marvinSmile(row): |
|