forked from dxsmiley/mathbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.html
More file actions
295 lines (266 loc) · 17 KB
/
docs.html
File metadata and controls
295 lines (266 loc) · 17 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Inconsolata|Josefin+Sans:300|Titillium+Web:300" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<title>MathBot</title>
</head>
<body>
<!-- <div class="navbox">
<p>
<a href="#">Support</a>
<a href="#">Donate</a>
</p>
</div> -->
<div class="doc-nav">
<a href="index.html"><p>Home</p></a>
<h1>Docs</h1>
<a href="#h-about"><p>About</p></a>
<a href="#h-wolfram"><p>Wolfram|Alpha</p></a>
<a href="#h-latex"><p>LaTeX</p></a>
<a href="#h-calculator"><p>Calculator</p></a>
<a href="#h-turing"><p>Turing Completeness</p></a>
<a href="#h-theme"><p>Themes</p></a>
<a href="#h-settings"><p>Settings</p></a>
<a href="#h-prefix"><p>Prefix</p></a>
<a href="#h-blame"><p>Blame</p></a>
<a href="#h-purge"><p>Purge</p></a>
</div>
<div class="doc-body">
<div>
<h1 id="h-about">About</h1>
<p>Add MathBot to your <a href="https://discordapp.com/oauth2/authorize?&client_id=172236682245046272&scope=bot&permissions=126016">server using this link</a>.</p>
<p>MathBot is developed by DXsmiley. You can talk to him via the <a href="https://discord.gg/JbJbRZS">official MathBot server</a>.</p>
<p>MathBot is written in Python using <a href="https://github.com/Rapptz/discord.py">discord.py</a>.</p>
<h1 id="h-wolfram">Wolfram|Alpha</h1>
<p>The <code>=wolf</code> command is used to query Wolfram|Alpha.</p>
<p>This command can be very slow at times, so please be patient.</p>
<p>You can use the <code>=theme</code> command to change the colour of the results.</p>
<h2>Examples</h2>
<p><code>=wolf intersection of sin(x) and cos(x)</code></p>
<p><code>=wolf x^3 - x^2 + x - 1</code></p>
<h2>Refining your results</h2>
<p>This command will give you <em>all</em> the information that Wolfram|Alpha spits out, which is often more than you want. It understand some english, so you can use words to refine your query. For example, you might use <code>roots of x^2 - x - 1</code> rather than <code>y = x^2 - x - 1</code> if you only want the solutions to the equation.</p>
<h2>Assumptions</h2>
<p>Sometimes Wolfram|Alpha will make some assumptions about your intentions. These will be displayed at the bottom of the message. If you wish to change what W|A assumes, you can click on the letter reactions (🇦, 🇧, etc...), and then click the 🔄 reaction to re-run the query.</p>
<h2>Query Filters</h2>
<p>To avoid people abusing the bot, some queries will not be run. The filter applies to all channels except for direct messages and channels marked as nsfw.</p>
<p>A server admin can be manually disable the filter in a channel by running <code>=set channel f-wolf-filter disable</code>.
It can be re-enabled again with <code>=set channel f-wolf-filter enable</code>.</p>
<p>See <code>=help settings</code> for more details on managing settings.</p>
<h1 id="h-latex">LaTeX</h1>
<p>The <code>=tex</code> command is used render <em>LaTeX</em> equations.</p>
<p>The <em>LaTeX</em> rendering is done by <a href="http://rtex.probablyaweb.site/">http://rtex.probablyaweb.site/</a></p>
<p>You can use the <code>=theme</code> command to change the colour of the results.</p>
<h2>Examples</h2>
<p><code>=tex x = 7</code></p>
<p><code>=tex \sqrt{a^2 + b^2} = c</code></p>
<p><code>=tex \int_0^{2\pi} \sin{(4\theta)} \mathrm{d}\theta</code></p>
<h2>Limitations</h2>
<p>The bot currently uses an external rendering service. The following features are known to break things:</p>
<ul>
<li><code>$</code> to start and end the equations. These are not required, and may do strange things. Use <code>\text{words}</code> to place text.</li>
<li><code>\usepackage</code>, for any reason.</li>
<li>Macros such as <code>\@ifpackageloaded</code>.</li>
<li>Loading of external images, and other resources.</li>
</ul>
<h2>Inline LaTeX</h2>
<p><em>This feature is currently disabled by default and must be turned on by the server owner. The server owner should run the command <code>=set server f-inline-tex enable</code>.</em></p>
<p>You can insert LaTeX into the middle of a message by wrapping it in <code>$$</code> signs.</p>
<p>Examples</p>
<p><code>The answer is $$x^{2 + y}$$.</code></p>
<p><code>$$1 + 2$$ equals $$3$$.</code></p>
<h2>Custom commands</h2>
<p>Some custom commands have been added to make typing quick LaTeX easy. These include <code>\bbR</code>, <code>\bbN</code> etc. for <code>\mathbb{R}</code>, <code>mathbb{N}</code> and other common set symbols and <code>\bigO</code> for <code>\mathcal{O}</code></p>
<h1 id="h-calculator">Calculator</h1>
<p>The calculator can be invoked with the command <code>=calc</code>.</p>
<p>It is also possible to use the shortcut <code>==</code>, however <em>this may be disabled on some servers or channels</em>. Using the shortcut will not produce an error message if it is disabled.</p>
<p>To see details on the calculator's Turing completeness, run <code>=help turing</code>.</p>
<p>The calculator supports the following arithmetic operations:</p>
<ul>
<li><code>+</code> : addition</li>
<li><code>-</code> : subtraction</li>
<li><code>*</code> : multiplication (can also use <code>×</code>)</li>
<li><code>/</code> : division (can also use <code>÷</code>)</li>
<li><code>^</code> : exponentiation (has some limitations to prevent exploits)</li>
<li><code>!</code> : factorial (cannot be applied to numbers greater than 200)</li>
</ul>
<p>The following comparisons are supported</p>
<ul>
<li><code>></code> : Greater than.</li>
<li><code><</code> : Less than.</li>
<li><code>==</code> : Equal to (two <code>=</code> signs for comparison)</li>
<li><code>>=</code> : Greater or equal.</li>
<li><code><=</code> : Less than or equal.</li>
<li><code>!=</code> : Not equal.</li>
</ul>
<p>For example, <code>2 < 5 < 8</code> evaluates to <code>True</code>, whereas <code>3 == 6</code> equates to <code>False</code>.</p>
<p>The following logical operators are supported:</p>
<ul>
<li><code>|</code> : Or (<code>x | y</code>)</li>
<li><code>&</code> : And (<code>x & y</code>)</li>
<li><code>!</code> : Not (<code>!x</code>)</li>
</ul>
<p>The value <code>0</code> is considered falsy. Everything else is truthy.</p>
<p>The following constants exist:</p>
<ul>
<li><code>pi</code> : 3.141592... (also <code>π</code>)</li>
<li><code>tau</code> : 6.283185... (twice pi)</li>
<li><code>e</code> : 2.178281...</li>
<li><code>true</code> : 1</li>
<li><code>false</code> : 0</li>
<li><code>i</code> : The imaginary unit</li>
</ul>
<p>The following functions are available:</p>
<ul>
<li><code>sin(x)</code> : sine of an angle (radians)</li>
<li><code>cos(x)</code> : cosine of an angle (radians)</li>
<li><code>tan(x)</code> : tan of an angle (radians)</li>
<li><code>sind(x)</code> : sine of an angle (degrees)</li>
<li><code>cosd(x)</code> : cosine of an angle (degrees)</li>
<li><code>tand(x)</code> : tan of an angle (degrees)</li>
<li><code>asin(x)</code> : inverse sine (radians)</li>
<li><code>acos(x)</code> : inverse cosine (radians)</li>
<li><code>atan(x)</code> : inverse tan (radians)</li>
<li><code>asind(x)</code> : inverse sine (degrees)</li>
<li><code>acosd(x)</code> : inverse cosine (degrees)</li>
<li><code>atand(x)</code> : inverse tan (degrees)</li>
<li><code>sinh(x)</code> : hyperbolic sine function</li>
<li><code>cosh(x)</code> : hyperbolic cosine function</li>
<li><code>tanh(x)</code> : hyperbolic tan function</li>
<li><code>asinh(x)</code> : inverse hyperbolic sine</li>
<li><code>acosh(x)</code> : inverse hyperbolic cosine</li>
<li><code>atanh(x)</code> : inverse hyperbolic tan</li>
<li><code>deg(r)</code> : converts radians to degrees</li>
<li><code>rad(d)</code> : converts degrees to radians</li>
<li><code>log(x)</code> : log in base 10</li>
<li><code>log(x, b)</code> : log of <code>x</code> in base <code>b</code></li>
<li><code>ln(x)</code> : log in base <code>e</code></li>
<li><code>sqrt(x)</code> : calculates the square root of a number</li>
<li><code>round(x)</code> : rounds a number to the nearest integer</li>
<li><code>int(x)</code> : rounds <em>down</em> to the nearest integer</li>
<li><code>gamma(x)</code> : computes the gamma function</li>
<li><code>gcd(a, b)</code> : computes the greatest common denominator or a and b</li>
<li><code>lcm(a, b)</code> : computes the lowest common multiple of a and b</li>
<li><code>choose(n, k)</code> : computes <code>n</code> choose <code>k</code></li>
<li><code>re(x)</code> : get the real part of a complex number</li>
<li><code>im(x)</code> : get the imaginary part of a complex number</li>
</ul>
<p>You can use the following notation to roll dice:</p>
<ul>
<li><code>dX</code> : rolls an <code>X</code>-sided die. (e.g. <code>d20</code>)</li>
<li><code>YdX</code> : rolls <code>Y</code> <code>X</code>-sided dice. (e.g. <code>2d6</code>) and gives the total.</li>
</ul>
<p>You cannot roll more than 1000 dice at once.</p>
<p>Appending the equation with <code>: R</code>, where <code>R</code> is an integer will repeat
the calculation that many times. Useful only if you want to roll many
dice at once. Using the <code>=csort</code> or <code>=sort</code> command will sort the numbers
in increasing order. <code>R</code> may not be greater than 50.</p>
<h2>Examples</h2>
<p><code>=calc 2 ^ (1 + 3) * 5</code></p>
<p><code>=calc round(10 / 3)</code></p>
<p><code>=calc sin(pi / 2)</code></p>
<p><code>=calc (4 + 3i) ^ 3</code></p>
<p><code>=calc 8d6 : 10</code></p>
<h1 id="h-turing">Turing Completeness</h1>
<p>The calculator is actually Turing complete, and can function as it's own small programming language, allowing you to perform more complicated operations.</p>
<p>Note that these features are currently in <em>beta</em> and may be unstable. More complete documentation will be coming later.</p>
<ul>
<li>Any variables that are assigned are contained to the channel that they are created in.</li>
<li>Values are purged at least once every 24 hours, so don't rely on the bot to store important information for you.</li>
</ul>
<h2>Assignments</h2>
<p>Assigning variables is simple:
<code>x = 7</code></p>
<p>Recalling them works the same as it normally would
<code>x</code></p>
<p>Note that the single-letter variable name <strong>d</strong> <em>cannot</em> be used, since it clashes with the die-rolling operator.</p>
<h2>If Statements</h2>
<p>If statements are use as follows:
<code>if(condition, expression_if_true, expression_if_false)</code></p>
<p>So for instance <code>if(1 < 2, 3, 4)</code> would evaluate to <code>3</code>, but <code>if(1 > 2, 3, 4)</code> would evaluate to <code>4</code>.</p>
<p>Unlike normal functions, the arguments that are passed to the <code>if</code> statement are only evaluated when they are used internally, not beforehand. This means that only one of <code>expression_if_true</code> and <code>expression_if_false</code> will ever be evaluated.</p>
<h2>Defining Functions</h2>
<p>Functions are defined using the following syntax
<code>(arguments, ...) -> expression</code></p>
<p>Example:
<code>(x, y, z) -> (x * y) / z</code></p>
<p>Functions are not given names, but they can be assigned to variables so that they may be used later.
<code>sum = (x, y) -> x + y
sum(3, 5)</code></p>
<h2>Macro Functions</h2>
<p>Macros are similar to normal functions, with the difference that all arguments have to be evaluated on demand: Your function gets a series of functions, which take no arguments and return the original value.</p>
<p>Macros are defined using the following syntax:
<code>(arguments, ...) ~> expression</code></p>
<p>For example, the following snippet will evaluate to <code>8</code>
<code>sum = (x, y) ~> x() + y()
sum(3, 5)</code></p>
<h2>Combining the two</h2>
<p>These tools are enough to create things such as the Fibonacci function:
<code>fib = (n) -> if (n < 2, 1, fib(n - 2) + fib(n - 1))</code></p>
<h2>Additional inbuilt functions</h2>
<p>There are also a number of additional inbuilt functions designed to help with building more complicated systems. There are described as follows:</p>
<ul>
<li><code>is_real(x)</code> - Determines whether x is a real number (an integer or a float).</li>
<li><code>is_complex(x)</code> - Determines whether x is a complex number.</li>
<li><code>is_function(x)</code> - Determines whether x is function (or a macro).</li>
</ul>
<h1 id="h-theme">Themes</h1>
<p>The <code>=theme</code> command is used to change the colour of the results for the <code>=tex</code> and <code>=wolf</code> commands.</p>
<p>Use <code>=theme dark</code> to apply the dark theme.
Use <code>=theme light</code> to apply the light theme.</p>
<p>The colours are designed to match Discord's dark and light schemes respectively.</p>
<p>Note that this only impacts commands that <em>you</em> invoke. If someone else calls one of the above commands, the results with use their chosen theme.</p>
<h1 id="h-settings">Settings</h1>
<p>MathBot has a number of settings that can be changed in order to modify its behaviour.</p>
<p>Most notably, server admins are able to enable or disable certain commands on their own servers, on a per-channel basis.</p>
<p>There are also settings for customising command output.</p>
<h2>Command Description</h2>
<p>The general structure of the settings command is:</p>
<p><code>=set context setting value</code></p>
<p><code>context</code> should be one of the following:</p>
<ul>
<li><code>server</code> - to apply the setting to the current server</li>
<li><code>channel</code> - to apply the setting to the current channel</li>
<li><code>self</code> - to apply the setting to yourself</li>
</ul>
<p><code>setting</code> should be the name of one of the settings, listed below.</p>
<p><code>value</code> should be a valid value for the setting. See below for details.</p>
<h2>Permission Settings</h2>
<p>These settings can be applied to the <code>server</code> and <code>channel</code> contexts, but only by server admins.</p>
<p><code>value</code> should be either <code>enable</code>, <code>disable</code>, or <code>original</code>. <code>enable</code> will allow people to use the command in the given context and <code>disable</code> will stop people from using it. <code>original</code> will reset the value to the default. Note that if both a server-wide option and a channel-specific option apply to a specific channel, setting the channel to <code>original</code> will mean that it defers to the setting used by the server.</p>
<ul>
<li><code>c-tex</code> : Enable or disable the <code>=tex</code> command. Default: Enabled</li>
<li><code>c-calc</code> : Enable or disable the <code>=calc</code> command. Default: Enabled</li>
<li><code>c-wolf</code> : Enable or disable the <code>=wolf</code> command. Default: Enabled</li>
<li><code>f-calc-shortcut</code> : Enable or disable the <code>==</code> shortcut for the <code>=calc</code> command. Disabling this <strong>will not</strong> produce an error message if a user attempts to use this command. This is intended to be used <em>only</em> if this command conflicts with other bots on your server. Default: Enabled</li>
<li><code>f-wolf-filter</code>: Enable or disable the word filter for W|A queries. This is enabled by default for all non-nsfw channels.</li>
<li><code>f-inline-tex</code>: Enable or disable the ability to add inline tex to messages. See <code>=help tex</code> for details. Default: <strong>Disabled</strong>.</li>
</ul>
<h2>Examples</h2>
<p>Disable the <code>=wolf</code> command on a server:
<code>=set server c-wolf disable</code></p>
<p>Enable the <code>=calc</code> command on a single channel:
<code>=set channel c-calc enable</code></p>
<h2>Troubleshooting</h2>
<p>Ensure you are typing words <em>exactly</em> as shown.
If you are still having problems you can ask <a href="https://discord.gg/JbJbRZS">on the official server</a>.</p>
<h1 id="h-prefix">Prefix</h1>
<p>Running <code>@MathBot prefix</code> with no arguments will simply display the bot's current prefix.</p>
<p>If you are a server admin, <code>@MathBot prefix new_prefix</code> will set the bot's prefix to <code>new_prefix</code> for the server. Use <code>@MathBot prefix =</code> to reset it to the default value.</p>
<p>In the case you want the prefix have leading or trailing whitespace, <code>new_prefix</code> should be wrapped in <em>backticks</em> (` symbols).</p>
<p>Prefix changes are reflected in the help commands when they are run from the server itself.</p>
<h1 id="h-blame">Blame</h1>
<p>The <code>=blame</code> command is used to find who caused the bot to post a certain message.</p>
<p>Usage: <code>=blame message_id</code></p>
<p>The <code>message_id</code> should be the id of the message that the bot posted. You can find this by enabling developer tools, and then right-clicking on the message you wish to investigate.</p>
<p>The bot keeps message blames for only 50 hours. After this, blame records are removed to conserve space.</p>
<h1 id="h-purge">Purge</h1>
<p><code>=purge number</code></p>
<p>This command will search through most recent <code>number</code> messages and delete any <em>that were sent by the bot</em>. The bot will not search more than the 500 most recent messages.</p>
<p>This command can only be run by users who have the <em>manage messages</em> permission in the respective channel. It will <em>not</em> work in any private channels.</p>
</div>
</div>
</body>
</html>