diff options
| author | 2018-08-31 04:14:56 +0100 | |
|---|---|---|
| committer | 2018-08-31 04:14:56 +0100 | |
| commit | 8d6f0fffa9822f9cfc6e354882a555d4df753a73 (patch) | |
| tree | bbb0e3a6c0e5c81645042ce1bb36317c9136dcce /Database.py | |
| parent | Update strax generator with a bunch of new phrases and attacks. (diff) | |
| signature | ||
Make channel values being inserted into SQLite integers if they're numbers.
Update ducks.py, you can now .bef and .bang! Coming soon: .friends, .killers, and .ducks
Update google to use gb instead of us. We're British goddamnit.
Diffstat (limited to 'Database.py')
| -rw-r--r-- | Database.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Database.py b/Database.py index 1c85f8ef..b9490af9 100644 --- a/Database.py +++ b/Database.py @@ -112,10 +112,24 @@ class ServerSettings(Table): [server_id, setting.lower()]) class ChannelSettings(Table): + def jsonKeys2int(self, x): + if isinstance(x, dict): + hold = {} + for k, v in x.items(): + key = int(k) if k.isdigit() else k + val = int(v) if v.isdigit() else v + + hold[key] = val + return hold + else: + return x + def set(self, channel_id, setting, value): + converted_json = self.jsonKeys2int(value) + self.database.execute( "INSERT OR REPLACE INTO channel_settings VALUES (?, ?, ?)", - [channel_id, setting.lower(), json.dumps(value)]) + [channel_id, setting.lower(), converted_json]) def get(self, channel_id, setting, default=None): value = self.database.execute_fetchone( """SELECT value FROM channel_settings WHERE |
