-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTursi_WhenGraphColor.muf
152 lines (150 loc) · 4.67 KB
/
Tursi_WhenGraphColor.muf
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
( Tursi's WhenGraph - inspired by Contimes - needs M3 )
( Displays the activity as it is automatically updated )
( The first day will be incorrectly aligned unless you )
( manually create a string with one space for each 30 )
( mins that have passed. You must also create 7 "old" )
( entries before you run it the first time, like so: )
( @set <program>=/Lines/0001:! <exclamation> )
( @set <program>=/Lines/0002:! )
( @set <program>=/Lines/0003:! ...etc )
( The number of lines you enter is the number of days )
( that will be displayed <once filled in> )
( Yes, it's manual and hacky, but it's also late! )
( Updated 20 Apr 02 to pad lines to the correct time )
( Updated 6 Jan 03 to track the best connects )
( Updated 15 Jan 03 to display the current number of )
( connects )
( Updated 07 Apr 03 by Marjan to display ANSI color )
( Updated 15 June 03 to fix ANSI color after fixing )
( the muck's code for ANSI_STRIP - Tursi )
$include $lib/strings
$include $lib/ansi
var start
$def LIMIT1 5
$def LIMIT2 15
$def LIMIT3 30
$def strcut ansi_strcut
$def strlen ansi_strlen
( Run the main loop )
( This function must run every 30 mins on the 30 mins to )
( update the connection count information )
: runLoop
background
systime timesplit ( we need to get how long it is until the half hour )
pop pop pop pop pop pop
dup 29 > if 30 - then ( no more than 30 mins )
60 * + ( get seconds )
1800 swap - ( get seconds left to go )
begin
sleep ( sleep until the half hour break )
( We awake - time to work )
systime dup timesplit
pop swap pop swap pop swap pop swap pop swap pop swap pop
prog "LastDay" getpropval over = not if
( we need to start a new stamp )
prog swap "LastDay" swap "" swap addprop
intostr "/Lines/" swap strcat
( we also need to delete the oldest one, assuming more than 7 )
prog "/Lines/" nextprop prog swap remove_prop
else
pop pop
"/Lines/" "0"
begin
swap prog swap nextprop
dup ansi_strip "" strcmp while
swap pop dup
repeat
pop
then
dup prog swap getpropstr
dup ansi_strip "" strcmp if
dup strlen 1 - strcut pop
then
( Work out how long the string SHOULD be, and make sure it is )
systime timesplit
pop pop pop pop pop
2 * swap
25 > if 1 else 0 then
+
swap pop
begin ( string len )
over strlen over < while
swap " " strcat swap
repeat
pop
( Now add today's count )
concount
( check for a record )
prog "_Record" getpropstr atoi over < if
dup intostr prog swap "_Record" swap 0 addprop
prog "_Date" "%e %B, %Y %k:%M" systime timefmt 0 addprop
then
dup LIMIT3 > if
"^RED^#"
else
dup LIMIT2 > if
"^YELLOW^*"
else
dup LIMIT1 > if
"^GREEN^+"
else
dup 0 > if
"^BLUE^."
else
" "
then
then
then
then
swap pop strcat ":" strcat ( the colon is padding to protect spaces )
prog -3 rotate 0 addprop
1800
repeat
;
( print a separator line )
: printseparator ( -- )
" ^CYAN^-----------------------------------------------------" .tell
;
( Main function )
: main
( check if this is startup )
"Startup" strcmp not if
me @ "W" flag?
loc @ #-1 dbcmp
or if
runLoop ( never actually exits )
else
"^WHITE^* Nice try." .tell
then
exit
then
"^CYAN^/-----------------------------------------------------\\" .tell
" ^WHITE^Muck Connections:^GREEN^ " concount intostr dup strlen -3 rotate strcat swap 2 / strcut swap pop .tell
" ^CYAN^------------^WHITE^A.M.^CYAN^--------------------^WHITE^P.M.^CYAN^-------------" .tell
" ^WHITE^1 1 1 1 1 1 " .tell
" ^WHITE^2 1 2 3 4 5 6 7 8 9 0 1 2 1 2 3 4 5 6 7 8 9 0 1 " .tell
printseparator
"/Lines/"
begin prog swap nextprop dup ansi_strip "" strcmp while
dup prog swap getpropstr
dup ansi_strip "!" strcmp if
dup ansi_strip "" strcmp if
dup strlen 1 - strcut pop
then
48 STRleft " ^WHITE^%a" strcat
"^WHITE^%d " swap strcat
over dup "/" rinstr strcut swap pop atoi
timefmt .tell
else
pop
then
repeat
printseparator
" ^BLUE^. ^WHITE^= 1-" LIMIT1 intostr strcat
" ^GREEN^+ ^WHITE^= " strcat LIMIT1 1 + intostr strcat "-" strcat LIMIT2 intostr strcat
" ^YELLOW^* ^WHITE^= " strcat LIMIT2 1 + intostr strcat "-" strcat LIMIT3 intostr strcat
" ^RED^# ^WHITE^= more than " strcat LIMIT3 intostr strcat .tell
printseparator
" ^WHITE^Most connections:^GREEN^ " prog "_Record" getpropstr atoi intostr strcat " ^WHITE^on^GREEN^ " strcat prog "_Date" getpropstr strcat .tell
"^CYAN^\\-----------------------------------------------------/" .tell
;