-
Notifications
You must be signed in to change notification settings - Fork 1
/
wowception
570 lines (501 loc) · 16.8 KB
/
wowception
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
#!/bin/bash
# __ __________ __ __ __ .__
#/ \ / \_____ \/ \ / \ ____ ____ _______/ |_|__| ____ ____
#\ \/\/ // | \ \/\/ // ___\/ __ \\____ \ __\ |/ _ \ / \
# \ // | \ /\ \__\ ___/| |_> > | | ( <_> ) | \
# \__/\ / \_______ /\__/\ / \___ >___ > __/|__| |__|\____/|___| /
# \/ \/ \/ \/ \/|__| \/
# by eimernase
# thanks to jwinterm, dsc_, lza_menace, martypete and everyone else from irc #wownero
# Settings
version="0.123456789"
memeviewer="sxiv"
description_text="SuchWow contribution :-)"
# Colors
cyan='\033[0;36m'
green='\033[1;32m'
purple='\033[0;35m'
red='\033[1;31m'
white='\033[1;37m'
yellow='\033[1;33m'
NC='\033[0m'
# Intermission
function error_syntax() {
echo -n "Syntax error... Press Return"; read
errorflag=true
}
function error_download_list() {
echo -n "You need to download the address list first... Press Return"; read
}
function error_download_memes() {
echo -n "You need to download the memes first... Press Return"; read
}
function error_tightwad() {
echo -n "Tightwad! Press Return"; read
}
function error_autosend() {
echo -n "Tipping more than 15 addresses at once needs automatic sending enabled... Press Return"; read
errorflag=true
}
function loading_please_hodl() {
echo -n "Loading... Please hodl"
echo ""
}
function how_much_wow() {
echo -n "How much?: "
read tipamount
echo""
if [[ $tipamount =~ ^[+]?[0-9]+\.?[0-9]*$ && "$tipamount" != "0" ]]; then
if (( $(echo "$tipamount > 0.0" | bc -l) )); then
sleep 0.1
else
error_syntax
fi
else
error_syntax
fi
}
function how_many_memes() {
echo -n "How many memes? [1-999]: "
read memeamount
echo ""
if [[ $memeamount =~ ^[+]?[0-9]+$ && "$memeamount" -gt "0" && "$memeamount" -le "999" ]]; then
if [[ "$autosend" == "false" && "$memeamount" -gt "15" && "$randomview" == "false" ]]; then
error_autosend
else
sleep 0.1
fi
else
error_syntax
fi
}
function how_many_seconds() {
echo -n "Send after how many seconds? [1-999]: "
read time_tx
echo ""
if [[ $time_tx =~ ^[+]?[0-9]+$ && "$time_tx" -gt "0" && "$time_tx" -le "999" ]]; then
sleep 0.1
else
error_syntax
fi
}
function how_many_seconds_check() {
echo -n "Check every how many seconds? [1-999]: "
read time_check
echo ""
if [[ $time_check =~ ^[+]?[0-9]+$ && "$time_check" -gt "0" && "$time_check" -le "999" ]]; then
sleep 0.1
else
error_syntax
fi
}
function which_one() {
echo -n "Which one? [1-"$(cat lastnumberofmemes)"]: "
read onememe
echo ""
if [[ $onememe =~ ^[+]?[0-9]+$ && "$onememe" -gt "0" && "$onememe" -le "$(cat lastnumberofmemes)" ]]; then
sleep 0.1
else
error_syntax
fi
}
# Leech all data from lza_menace :P
function get_addresses() {
# Purge old addresses
if [ -f addresses ]; then
rm addresses
fi
# Get total number of memes on suchwow.xyz
number_of_memes=$(elinks -dump -no-numbering https://suchwow.xyz | grep -E -A 1 'content=latest_tipped' | sed -e 's/^[ \t]*//' | tail -n 1) && number_of_memes=$(echo "${number_of_memes: -4}")
# Get all wownero addresses from suchwow.xyz
for i in $(seq 1 $number_of_memes); do
elinks -dump -no-numbering https://suchwow.xyz/post/$i | grep -E -A 1 "Vote for this post by sending WOW to the following address:" | sed -e 's/^[ \t]*//' | tail -n 1 >> addresses
sleep 0.1
done
#number_of_memes_last=$number_of_memes # do it via file instead of variable to be persistent between sessions
echo "$number_of_memes" > lastnumberofmemes_addresses
# Sort and remove duplicates
cat addresses | sort | uniq > addresses_sort_uniq
}
function get_last_addresses() {
# Only if addresses were already downloaded
if [ -f addresses ]; then
# Get total number of memes on suchwow.xyz
number_of_memes=$(elinks -dump -no-numbering https://suchwow.xyz | grep -E -A 1 'content=latest_tipped' | sed -e 's/^[ \t]*//' | tail -n 1) && number_of_memes=$(echo "${number_of_memes: -4}")
number_to_start=$(( $number_of_memes - $(cat lastnumberofmemes_addresses) ))
number_to_start=$(( $number_of_memes - $number_to_start ))
# Get all new wownero addresses from suchwow.xyz
if [[ $number_of_memes -gt $number_to_start ]]; then
for i in $(seq $number_to_start $number_of_memes); do
elinks -dump -no-numbering https://suchwow.xyz/post/$i | grep -E -A 1 "Vote for this post by sending WOW to the following address:" | sed -e 's/^[ \t]*//' | tail -n 1 >> addresses
sleep 0.1
done
fi
echo "$number_of_memes" > lastnumberofmemes_addresses
# Sort and remove duplicates
cat addresses | sort | uniq > addresses_sort_uniq
else
error_download_list
fi
}
function get_memes() {
# Purge old memes
if [ -d "memes" ]; then
rm -r memes
fi
# Create meme folder
mkdir memes
# Get total number of memes on suchwow.xyz
number_of_memes=$(elinks -dump -no-numbering https://suchwow.xyz | grep -E -A 1 'content=latest_tipped' | sed -e 's/^[ \t]*//' | tail -n 1) && number_of_memes=$(echo "${number_of_memes: -4}")
# Get meme name and download meme
for i in $(seq 1 $number_of_memes); do
w3m -dump_source https://suchwow.xyz/post/$i | grep -io 'https://suchwow.xyz.*[jpg|jpeg|gif|png]' | tail -n 1 | xargs wget -O memes/$i
done
#number_of_memes_last=$number_of_memes # do it via file instead of variable for persistency between sessions
echo "$number_of_memes" > lastnumberofmemes
get_stats
}
function get_last_memes() {
# Get total number of memes on suchwow.xyz
number_of_memes=$(elinks -dump -no-numbering https://suchwow.xyz | grep -E -A 1 'content=latest_tipped' | sed -e 's/^[ \t]*//' | tail -n 1) && number_of_memes=$(echo "${number_of_memes: -4}")
number_to_start=$(( $number_of_memes - $(cat lastnumberofmemes) ))
number_to_start=$(( $number_of_memes - $number_to_start ))
#if [ $number_of_memes -gt $(cat lastnumberofmemes) ]; then
# Get meme name and download meme
if [[ $number_of_memes -gt $number_to_start ]]; then
for i in $(seq $number_to_start $number_of_memes); do
w3m -dump_source https://suchwow.xyz/post/$i | grep -io 'https://suchwow.xyz.*[jpg|jpeg|gif|png]' | tail -n 1 | xargs wget -O memes/$i
done
fi
echo "$number_of_memes" > lastnumberofmemes
get_stats
}
function get_stats() {
if [[ $number_of_memes -gt $number_to_start ]]; then
echo "Meme download complete."
else
echo "No new memes available."
fi
# echo "Getting stats..."
# Get number of memers
# elinks -dump -no-numbering https://suchwow.xyz/leaderboards/top_posters | tail -n +12 | sed '/Go Home/,$d' | head -n -3 > userbase
# memers=$(cat userbase | wc -l)
# Get all WOW ever tipped
# cat userbase | sed -r 's/1e-11/0.00000000001/' | cut -c 52- | rev | cut -c 4- | rev | paste -sd+ | bc -l > tippedamount
# echo "Stats download complete."
echo "Getting addresses..."
}
# Tips
function answer_tip() {
read tipanswer
echo""
case $tipanswer in
y ) transfer_chunks
;;
n ) error_tightwad
;;
* ) error_syntax
esac
}
function tip_all() {
if [ -f addresses ]; then
# Calculate tip amount
manyaddresses=$(cat addresses_sort_uniq | wc -l)
eachamount=$(echo "scale=11; "$tipamount/$manyaddresses"" | bc -l)
# Add tip amount to new addressfile
cp addresses_sort_uniq addresses_with_amount
sed -i s/$/", $eachamount"/ addresses_with_amount # add to end of each line
# Display tip amount
echo -n "That's "$eachamount" for everyone. Are you sure? (y/n): "
answer_tip
else
error_download_list
fi
}
function tip_latest() {
if [ -f addresses ]; then
cat addresses | uniq | tail -n $memeamount > addresses_uniq
# Calculate tip amount
manyaddresses=$(cat addresses_uniq | wc -l)
eachamount=$(echo "scale=11; "$tipamount/$manyaddresses"" | bc -l)
# Add tip amount to new addressfile
cp addresses_uniq addresses_with_amount
sed -i s/$/", $eachamount"/ addresses_with_amount # add to end of each line
# Display tip amount
echo -n "That's "$eachamount" for everyone. Are you sure? (y/n): "
answer_tip
else
error_download_list
fi
}
function tip_donate() {
# Add tip amount to new addressfile
echo "WW45jxyyxZpRLuKyAM7KfH21NK2W1RwqJSu9mwaQ49YYfCKf7EfAMoAi3sB47EFHTj393us29SffyLynCGEYpb5W2xRxDi3G9" > addresses_with_amount
sed -i s/$/", $tipamount"/ addresses_with_amount # add to end of line
# Display tip amount
echo -n "Donate "$tipamount" to WOWception. Are you sure? (y/n): "
answer_tip
}
function tip_one() {
# Get donation address from suchwow.xyz
elinks -dump -no-numbering https://suchwow.xyz/post/$onememe > sitedata && grep -E -A 1 "Vote for this post by sending WOW to the following address:" sitedata | sed -e 's/^[ \t]*//' | tail -n 1 > single_address
sleep 0.1
if grep -q -E -A 1000000 "No WOW received yet" sitedata; then
totaltipamount="0.0"
else
totaltipamount=$(sed -i '/WOW Sent/,$d' sitedata && grep -E -A 1000000 "WOW Received" sitedata | sed -r 's/1e-11/0.00000000001/' | tail -n +3 | head -n -1 | sed -e 's/^[ \t]*//' | cut -c 6- | cut -d' ' -f1 | paste -sd+ | bc)
fi
# Add tip amount to new addressfile
cp single_address addresses_with_amount
sed -i s/$/", $tipamount"/ addresses_with_amount # add to end of line
# Display tip amount
echo -n "That's "$tipamount" for the memer. Tips so far: "$totaltipamount". Are you sure? (y/n): "
answer_tip
}
function tip_random() {
if [ -f addresses ]; then
# Pick random addresses
cat addresses | sort | uniq | sort --random-sort | head -n $memeamount > random_addresses_sort_uniq
# Calculate tip amount
manyaddresses=$(cat random_addresses_sort_uniq | wc -l)
eachamount=$(echo "scale=11; "$tipamount/$manyaddresses"" | bc -l)
# Add tip amount to new addressfile
cp random_addresses_sort_uniq addresses_with_amount
sed -i s/$/", $eachamount"/ addresses_with_amount # add to end of each line
# Display tip amount
echo -n "That's "$eachamount" for everyone. Are you sure? (y/n): "
answer_tip
else
error_download_list
fi
}
function transfer_chunks() {
while [ -s addresses_with_amount ]; do
# Check if only one address is left
if [[ $(cat addresses_with_amount | wc -l) = "1" ]]; then
single_transfer=true
fi
# Copy top 15 addresses
cat addresses_with_amount | head -n 15 | xclip -selection c
# Remove top 15 addresses from file
sed -i '1,15d' addresses_with_amount
operate_wowlet_transfer
done
}
function operate_wowlet_transfer() {
# Focus WOWlet wallet and insert addresses
xdotool mousemove --window $(xdotool search --name "WOWlet -") 200 35 click 1 mousemove --window $(xdotool search --name "WOWlet -") 200 80 click 1
xdotool key --repeat 10 shift+Tab key space # clear everything firest
xdotool mousemove --window $(xdotool search --name "WOWlet -") 200 35 click 1 mousemove --window $(xdotool search --name "WOWlet -") 200 80 click 1
# wmctrl -a WOWlet && sleep 0.1
xdotool key ctrl+v
# Fill in description
xdotool key --repeat 12 shift+Tab
echo "$description_text" | xclip -selection c
xdotool key ctrl+v
xdotool key --repeat 3 Tab
xdotool key space
if $autosend; then
# One tx
if $single_transfer; then
# Send one
single_transfer=false
sleep $time_tx
xdotool key Tab
xdotool key space
sleep 1
xdotool key Return
wmctrl -a wowception
# Pay to many
else
sleep $time_tx
xdotool key --repeat 5 Tab
xdotool key space
sleep 1
xdotool key Return
wmctrl -a wowception
fi
fi
}
function view_newest() {
dircount=$(ls -1A memes | wc -l)
if [ $dircount -eq 0 ]; then
error_download_memes
else
rm memes/list; rm listnew; ls memes | sort -n > listnew && tac listnew > list && cp list memes/list && cd memes && $memeviewer -a -i < list & disown
# OLDDISPLAY=$DISPLAY && DISPLAY=':0' && rm memes/list; rm listnew; ls memes | sort -n > listnew && tac listnew > list && cp list memes/list && cd memes && $memeviewer -a -i < list & disown ; DISPLAY=$OLDDISPLAY
# rm memes/list; ls memes | sort -n > list && cd memes && $memeviewer -a -i < ../list ; cd ..
fi
}
function view_thumbnail() {
dircount=$(ls -1A memes | wc -l)
if [ $dircount -eq 0 ]; then
error_download_memes
else
rm memes/list; ls memes | sort -n > list && cp list memes/list && cd memes && $memeviewer -a -t -i < list & disown
fi
}
function view_one() {
dircount=$(ls -1A memes | wc -l)
if [ $dircount -eq 0 ]; then
error_download_memes
else
$memeviewer -a memes/$onememe & disown
# rm memes/list; ls memes | sort -n > list && cp list memes/list && cd memes && $memeviewer -a -i < list -n $onememe ; cd ..
fi
}
function view_random() {
dircount=$(ls -1A memes | wc -l)
if [ $dircount -eq 0 ]; then
error_download_memes
else
rm memes/list; ls memes | sort -n > rawlist && cat rawlist | sort --random-sort | head -n $memeamount > list && cp list memes/list && cd memes && $memeviewer -S 5 -f -a -i < list & disown
fi
}
function change_autosend() {
if $autosend; then
autosend=false
else
how_many_seconds
if ! $errorflag; then autosend=true; fi
fi
}
function change_autocheck() {
if $autocheck; then
autocheck=false
pkill -9 memechecker
else
how_many_seconds_check
if ! $errorflag; then
autocheck=true
./memechecker "$time_check" & disown
fi
fi
}
# Menu
pkill -9 memechecker
tipamount=
selection=
totaltipped=
autosend=false
autocheck=false
randomview=false
until [ "$selection" = "e" ]
do clear -x
errorflag=false
echo '
__ __________ __ __ __ .__
/ \ / \_____ \/ \ / \ ____ ____ _______/ |_|__| ____ ____
\ \/\/ // | \ \/\/ // ___\/ __ \\____ \ __\ |/ _ \ / \
\ // | \ /\ \__\ ___/| |_> > | | ( <_> ) | \
\__/\ / \_______ /\__/\ / \___ >___ > __/|__| |__|\____/|___| /
\/ \/ \/ \/ \/|__| \/' | lolcat
echo -e "
${purple}. version${white} $version ${NC}"
echo -en " ${purple}. latest meme${white} "
if [ -f lastnumberofmemes ]; then
cat lastnumberofmemes
else
echo 'N/A'
fi
# echo -n " . memers "
# if [ -f userbase ]; then
# cat userbase | wc -l
# else
# echo 'N/A'
# fi
# echo -n " . tipped "
# if [ -f tippedamount ]; then
# cat tippedamount | cut -c1-17
# else
# echo 'N/A'
# fi
echo -e "
${white}g -${NC} (Re)Download all memes and donation addresses from suchwow.xyz (takes a while...)
${white}u -${NC} Update all memes and donation addresses since last download"
if $autocheck; then
echo -e " ${white}a -${NC} Autocheck for new memes every x seconds and display notification ${green}- ON ($time_check)${NC}"
else
echo -e " ${white}a -${NC} Autocheck for new memes every x seconds and display notification ${red}- OFF${NC}"
fi
echo -e "
${white}v -${NC} View memes beginning with the newest (n and p to rifle through, f for fullscreen)
${white}x -${NC} View meme number x
${white}t -${NC} View memes in thumbnail mode
${white}r -${NC} View some random memes as a fullscreen slideshow
"
if $autosend; then
echo -e " ${white}s -${NC} Send automatically after x seconds ${green}- ON ($time_tx)${NC}"
else
echo -e " ${white}s -${NC} Send automatically after x seconds ${red}- OFF${NC}"
fi
echo -e " ${white}1 -${NC} Tip meme number x
${white}2 -${NC} Tip the x latest memes
${white}3 -${NC} Random tip a number of memes
${white}4 -${NC} Tip ALL memes (use with caution!)
${white}5 -${NC} Mock meme with 0.00000000001 WOW
${white}c -${NC} Call martypete tech support (better not)
${yellow}d -${NC} Donate some WOW to WOWception
${white}e -${NC} Exit
"
echo -en "${white}Enter selection: "
read selection
echo ""
case $selection in
g ) loading_please_hodl
get_memes
get_addresses
;;
u ) loading_please_hodl
get_last_memes
get_last_addresses
;;
a ) change_autocheck
;;
1 ) if ! $errorflag; then which_one; fi
if ! $errorflag; then how_much_wow; fi
if ! $errorflag; then tip_one; fi
;;
2 ) if ! $errorflag; then how_many_memes; fi
if ! $errorflag; then how_much_wow; fi
if ! $errorflag; then tip_latest; fi
;;
3 ) if ! $errorflag; then how_many_memes; fi
if ! $errorflag; then how_much_wow; fi
if ! $errorflag; then tip_random; fi
;;
4 ) if $autosend; then
if ! $errorflag; then how_much_wow; fi
if ! $errorflag; then tip_all; fi
else
error_autosend
fi
;;
5 ) tipamount=0.00000000001
if ! $errorflag; then which_one; fi
if ! $errorflag; then tip_one; fi
;;
s ) change_autosend
;;
v ) view_newest
;;
x ) if ! $errorflag; then which_one; fi
if ! $errorflag; then view_one; fi
;;
t ) view_thumbnail
;;
r ) randomview=true
if ! $errorflag; then how_many_memes; fi
if ! $errorflag; then view_random; fi
;;
c ) echo -en "Martypete fucks you up and deletes a few random files on your hard disk... Press Return"; read
;;
d ) if ! $errorflag; then how_much_wow; fi
if ! $errorflag; then tip_donate; fi
;;
e ) pkill -9 memechecker
exit
;;
* ) error_syntax
esac
done