1
2
3
4
5 """ ignore module """
6
7 __copyright__ = 'this file is in the public domain'
8
9 from gozerbot.persist import Persist
10 from gozerbot.datadir import datadir
11 from gozerbot.periodical import interval
12 import time, os, thread
13
14 ignore = Persist(datadir + os.sep + 'ignore')
15 timeset = Persist(datadir + os.sep + 'ignoretimeset')
16
17 if not ignore.data:
18 ignore.data = {}
19
20 if not timeset.data:
21 timeset.data = {}
24 """ add ignore based on userhost .. record time when ignore is set """
25 ignore.data[userhost] = int(ttime)
26 timeset.data[userhost] = time.time()
27 ignore.save()
28 timeset.save()
29
31 """ remove ignore """
32 try:
33 del ignore.data[userhost]
34 ignore.save()
35 del timeset.data[userhost]
36 timeset.save()
37 return 1
38 except KeyError:
39 return 0
40
42 """ check if we should ignore """
43 try:
44 ignoretime = ignore.data[userhost]
45 ignoreset = timeset.data[userhost]
46 except KeyError:
47 return 0
48 if time.time() - ignoretime < ignoreset:
49 return 1
50 return 0
51
57
58 ignorecheck()
59