diff options
author | Livio Recchia <recchialivio@libero.it> | 2020-02-10 23:06:34 +0100 |
---|---|---|
committer | Livio Recchia <recchialivio@libero.it> | 2020-02-10 23:06:34 +0100 |
commit | 9a13903a2f7d3a65fdf15a65fb59cccd622e2066 (patch) | |
tree | 9403b7dff39eb5e5d7fa0f79efb69b496add4c4b /playerlist.py | |
parent | 11cc316b74d5f3f283413a33e7693b314741aa4a (diff) | |
download | manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.gz manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.bz2 manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.xz manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.zip |
Initial commit
Diffstat (limited to 'playerlist.py')
-rw-r--r-- | playerlist.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/playerlist.py b/playerlist.py new file mode 100644 index 0000000..e8db995 --- /dev/null +++ b/playerlist.py @@ -0,0 +1,28 @@ +import os + + +class PlayerList: + def __init__(self, fn): + self._filename = fn + self._last_modified = os.path.getmtime(fn) + self._list = self._load_file(fn) + + def _load_file(self, fn): + self._list = [] + with open(fn, 'r') as f: + for l in f: + self._list.append(l.strip()) + return self._list + + def check_player(self, pn): + if pn in self._list: + return True + else: + lm = os.path.getmtime(self._filename) + if lm != self._last_modified: + self._last_modified = lm + self._load_file(self._filename) + if pn in self._list: + return True + + return False |