/
misc.py
46 lines (41 loc) · 1.45 KB
/
misc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#miscelaneous hexlight output commands
# complicated enough for a file
# but not enough for a dedicated file
import out
import patterns
import twitterclock
import letters as ls
class clock_say:
def __init__(self, message):
self.message = message
def __call__(self):
print self.message
for char in self.message:
if char not in ls.letter_dict:
continue
out.set_states_all(ls.letter_dict[char])
sleep(1)
patterns.all_off().draw()
sleep(0.05)
sleep(5)
return
# Tweet help statements back to the user
def tweethelp(thandle, command, options):
thandle = twitterclock.tclock()
user = thandle.get_mentions_user()
if options == 'help':
text = "tweet 'help: subject' where subject = {say,clock,life}"
elif options == 'say':
text = "say: string || prints out 'string' to the display"
elif options == 'clock':
text = "clock: options || enables clock-mode where options = {analog,digital}"
elif options == 'life':
text = "life: selfstr goodstr negastr threshold numberon waittime || all optional"
else:
text = "I don't understand you. Tweet 'help: help' for a list of commands."
tweet = '@%s %s' % (user,text)
# Check that we didn't just post this message - we don't want to spam
lastpost = thandle.get_last_post()
if not tweet == lastpost:
thandle.post_text(tweet)
return