-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
71 lines (52 loc) · 1.41 KB
/
app.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
#!/usr/bin/env python3.6
from os import getenv
from subprocess import getoutput
from discord.ext.commands import Bot
separator = '#' * 40
description = '''Soy Julia-tan, el bot de Discord del servidor de JuliaLangEs!'''
bot = Bot(command_prefix='jl>', description=description)
@bot.event
async def on_ready():
print(
f"""
{separator}
Julia-tan JuliaLangEs Discord bot.
BOT NAME: {bot.user.name}
BOT ID : {bot.user.id}
{separator}
"""
)
@bot.command()
async def julia(*, command: str):
try:
if command.startswith("```julia\n"):
command = command[9:-3]
elif command.startswith("```\n"):
command = command[4:-3]
elif command.startswith("`"):
command = command[1:-1]
result = getoutput(f"julia -e {command}")
await bot.say(
f"""
```julia
julia> {command}
{result}
```
"""
)
except error:
await bot.say(
f"""
Ooopss...
Comando:
```julia
{command}
```
Error:
```python
{error}
```
"""
)
if __name__ == '__main__':
bot.run(getenv("DISCORD_BOT_TOKEN"))