phschon / ultrabot Goto Github PK
View Code? Open in Web Editor NEWUltraBot - Yet another discord bot written in python
UltraBot - Yet another discord bot written in python
As noted by @00steinsgate00 in #1, a module system which is able to load arbitrary modules from a module directory would be noice.
Suggested architecture:
Create a generic baseclass for plugins. Not sure on python best practices, but as far as I understand it, you define all methods you want and just throw NotImplementedError
s. We probably need
prefix()
- the prefix part of the command. E.g. 'swag' or 'random'help()
- return a help messageexecute(args)
- execute a command where args are the parameters excluding the prefix, e.g. '2d6'At startup, scan all files in modules/
for python files. For each matching file, load it dynamically. See here for sample code
On each module loaded that way, call some predefined method (e.g. initialize()
) which should return an object implementing the ABC from above
The plugin can then be registered internally
@00steinsgate00
Entering !howlong tomb raider
yields the following stack trace:
future: <Task finished coro=<Howlongtobeat.execute() done, defined at /home/elazar/discordbot/plugins/howlongtobeat.py:33> exception=HTTPException('BAD REQUEST (status code: 400)',)>
Traceback (most recent call last):
File "/home/elazar/discordbot/plugins/howlongtobeat.py", line 63, in execute
await self.client.send_message(message.channel, response_message)
File "/home/elazar/discordbot/env/lib/python3.6/site-packages/discord/client.py", line 1152, in send_message
data = yield from self.http.send_message(channel_id, content, guild_id=guild_id, tts=tts, embed=embed)
File "/home/elazar/discordbot/env/lib/python3.6/site-packages/discord/http.py", line 200, in request
raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400)
@00steinsgate00 I think this is not intended.
Especially now since the new methods have been added I think we need some more documentation.
I tried to figure out how to use the event system and I couldn't, the code is just a bunch of methods with no comments
I have no idea what I have to do actually.
Furthermore I think we should document the base class and what the methods are for. I know there is an example template but it's better to have some proper documentation. Plus the template does not call the super constructor which is very very bad practice in my opinion.
I see that the main bot loop uses await a lot when sending messages. Is this really necessary? I assume the bot would run a bit smoother if dropping it.
@00steinsgate00 , I think your Plugin behaves not as intended. When using commands like !pr0 epic_mount
the bot does not yield any output on a discord channel.
On the console the following error is displayed:
Task exception was never retrieved future: <Task finished coro=<pr0gramm.execute() done, defined at /home/elazar/discordbot/plugins/image_post.py:31> exception=IndexError('list index out of range',)> Traceback (most recent call last): File "/home/elazar/discordbot/plugins/image_post.py", line 33, in execute random_item = self._getRandomItem(command) File "/home/elazar/discordbot/plugins/image_post.py", line 63, in _getRandomItem return items[random.randint(0, len(items))] IndexError: list index out of range
Because SUCH SPEED much safety wow
Rust is our lord and savior
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.