diff options
author | Santo Cariotti <sancn@live.com> | 2017-07-20 10:30:10 +0200 |
---|---|---|
committer | Santo Cariotti <sancn@live.com> | 2017-07-20 10:30:10 +0200 |
commit | bdf83e42d1bca4ffac3a03bfdbb27d06db74dc88 (patch) | |
tree | e408c50422e4159a0008c5e529a8be6308a0f445 /commands.py | |
parent | b50e32c9f6436b6e7d84502586b3bd04bb7dfd6a (diff) |
now there are more files
Diffstat (limited to 'commands.py')
-rw-r--r-- | commands.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/commands.py b/commands.py index e69de29..2c7b57f 100644 --- a/commands.py +++ b/commands.py @@ -0,0 +1,28 @@ +from classes import userexist, PersonalError, r, host +from listcommands import ListCommands + +class Commands(object): + + def command(self, what, cmd): + if what == 'clear': + clear() + elif what == 'set': + try: + if cmd[1] == 'user' and cmd[2] is not None: + if len(cmd[2]) > 10: raise PersonalError("lunghezza maggiore del consetito. Max 10") + + if userexist(cmd[2]) == True: raise PersonalError("questo nome utente esiste giĆ ") + + if self.user != '': r.zrem('usersname', self.user) + + self.user = cmd[2] + r.hset('user:'+host, 'name', self.user) + r.zadd('usersname', self.user, 0) + + print("Ok") + elif cmd[1] is not ListCommands.commands['set']: + raise IndexError + except IndexError: + ListCommands.err('wrong') + except PersonalError as e: + ListCommands.err('personal', e.value) |