This repository was archived by the owner on May 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwordbot.py
More file actions
104 lines (53 loc) · 2.14 KB
/
wordbot.py
File metadata and controls
104 lines (53 loc) · 2.14 KB
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
import requests
import json
def get_word(count, word_set=''):
if word_set != '':
word_set = '&set=' + word_set
r = requests.get(f'https://api.noopschallenge.com/wordbot?count={count}{word_set}')
words = json.loads(r.content)["words"]
return words
def get_sets():
r = requests.get(f'https://api.noopschallenge.com/wordbot/sets')
sets = json.loads(r.content)
return sets
def clear():
print('\n' * 50)
def start():
clear()
print('Welcome to the sentance builder... the most useless "keyboard" ever')
print('You can type in "help" to show the available commands')
input('Press enter to start: ')
def show_sets():
for i in range(len(sets)):
print(f'[{i}] {sets[i]}')
def show_commands():
print('sets - shows the available sets')
print('addword - adds a word to the sentance')
print('fromset <NUM> - add a word from a set, add the set number to the end')
print('output - show the created sentance')
print('input - add your own words to the sentance')
print('clear - clear the console')
print('tofile <filename> - output the sentance to a txt file [no spaces]')
def main():
clear()
sentance = ''
while (cmd := input('[>> ').lower().strip()) != 'q':
if cmd == 'help' or cmd == 'h' : show_commands()
if cmd == 'sets' : show_sets()
if cmd == 'addword': sentance += get_word(1)[0] + ' '
if cmd == 'output' : print('\n\nSentance: ' + sentance + '\n\n')
if cmd.split(' ')[0] == 'input' : sentance += cmd[5:len(cmd)].strip() + ' '
if cmd == 'clear' : clear()
if cmd.split(' ')[0] == 'tofile':
with open('{}.txt'.format(cmd.split(' ')[1]), 'w') as file:
file.write(sentance)
if cmd.split(' ')[0] == 'fromset':
try:
sentance += get_word(1, sets[int(cmd.split(' ')[1])])[0].strip() + ' '
except IndexError:
pass
sets = get_sets()
count = 20
words = get_word(count)
start()
main()