-
Notifications
You must be signed in to change notification settings - Fork 1
/
readme.py
114 lines (90 loc) · 2.69 KB
/
readme.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
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
import snakemd
from pymon import brain
doc = snakemd.new_doc("README")
doc.add_header("Pymon")
doc.add_paragraph(
"""
Pymon was developed to help students find answers to course questions.
It is not currently hosted for public use, but you can self-host it using the
code found in this repo. Currently, I am running the bot on a home desktop.
"""
)
doc.add_header("How to Run the Bot", 2)
doc.add_paragraph(
"""
If you'd like to use this bot in your own server, start by cloning/forking this repo.
After that, you'll want to create a .env file in the root directory of the repo
with the following contents:
"""
)
doc.add_code(
"DISCORD_TOKEN=[insert token here]",
"env"
)
doc.add_paragraph(
"""
If you'd like to include your own knowledge base, you can do so by also creating
a KNOWLEDGE_PATH environment variable in your .env file. This should point to a
local file or a remote URL. Otherwise, the bot will use the queries.json file,
which is designed specifically for a course I am teaching.
"""
)
doc.add_code(
"KNOWLEDGE_PATH=[insert path here]",
"env"
)
doc.add_paragraph(
"""
After that, you'll want to install all requirements. Luckily, I've included a
requirements.txt file. You can use the following code to install all
requirements:
"""
)
doc.add_code(
"pip install -r requirements.txt",
"shell"
)
doc.add_paragraph(
"""
From there, you can run the bot like any other Python script:
"""
)
doc.add_code(
"python3 pymon.py",
"shell"
)
doc.add_header("How to Use the Bot", 2)
doc.add_paragraph(
"""
Pymon currently has two main services. First, you
can directly @ the bot to get it to respond with the top three
matching questions to your query. The response will include an ID
which you can lookup with the `/get` command. Alternatively,
you can use the list in the next section directly. Note that the
questions don't have any organization, so asking the bot to give
you some matches is sometimes a better start.
"""
)
doc.add_header("Question IDs", 2)
doc.add_paragraph(
"""
Currently, the bot can answer the following questions.
The numbers map directly to the lookup IDs, so if you want
an answer to any of these questions, just ask the bot with
`/get`.
"""
)
questions = []
pymon_brain = brain.Brain()
queries = pymon_brain.get_all_queries()
for query in queries:
item = f"\"{query.query}\" by {', '.join(query.authors)}"
questions.append(item)
doc.add_ordered_list(questions)
doc.add_horizontal_rule()
doc.add_paragraph(
"""
This README was automatically generated using SnakeMD.
"""
)
doc.output_page()