Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit017b94e

Browse files
author
appositum
committed
Basic plot setup
1 parenta84e6c6 commit017b94e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

‎bot.py‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#!/usr/bin/env python3
22

33
importos
4+
fromosimportpath
45

6+
importsympyassyp
57
fromdiscord.ext.commandsimportBot
68

79

8-
bot=Bot(command_prefix="plot")
10+
bot=Bot(command_prefix="p$")
911
TOKEN=os.environ.get("TOKEN")
1012

13+
ifnotpath.exists('.log'):os.mkdir('.log')
14+
log_dir=path.abspath('.log')
15+
1116

1217
@bot.event
1318
asyncdefon_ready():
@@ -21,4 +26,15 @@ async def hello(*args):
2126
returnawaitbot.say('Hello world!')
2227

2328

29+
@bot.command(pass_context=True)
30+
asyncdefplot(ctx,*,exp):
31+
exp=syp.sympify(exp)
32+
33+
img_path=path.join(log_dir,'figure.png')
34+
img=syp.plot(exp,show=False)
35+
img.save(img_path)
36+
37+
returnawaitbot.upload(img_path)
38+
39+
2440
bot.run(TOKEN)ifTOKENelseprint('TOKEN environment variable not set!')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp