Changing name+structure
This commit is contained in:
@@ -4,3 +4,8 @@ __pycache__
|
||||
.env
|
||||
error_*
|
||||
*.log
|
||||
test.py
|
||||
*.pyc
|
||||
.pytest_cache
|
||||
.coverage
|
||||
tmp
|
||||
@@ -0,0 +1,62 @@
|
||||
[](https://lgtm.com/projects/g/Klemek/miniscord/alerts/)
|
||||
[](https://lgtm.com/projects/g/Klemek/miniscord/context:python)
|
||||
[](https://coveralls.io/github/Klemek/miniscord?branch=master)
|
||||
|
||||
# Miniscord
|
||||
*A minimalist discord bot API*
|
||||
|
||||
```python
|
||||
from miniscord import Bot
|
||||
import discord
|
||||
|
||||
|
||||
async def hello(client: discord.client, message: discord.Message, *args: str):
|
||||
await message.channel.send("Hello!")
|
||||
|
||||
|
||||
bot = Bot(
|
||||
"test-app", # name
|
||||
"0.1-alpha", # version
|
||||
alias="|" # respond to '|command' messages
|
||||
)
|
||||
bot.register_command(
|
||||
"hello", # command text (regex)
|
||||
hello, # command function
|
||||
"hello: says 'Hello!'", # short help
|
||||
f"```\n" # long help
|
||||
f"* |help\n"
|
||||
f"\tSays 'Hello!'.\n"
|
||||
f"```"
|
||||
)
|
||||
bot.start()
|
||||
# this bot respond to "|help", "|info" and "|hello"
|
||||
```
|
||||
|
||||

|
||||
|
||||
> **⚠ Disclaimer:** I intend to use this project personally, I'm open to ideas but I don't care if it doesn't work for you. Same for the name, feel free to use it, I'm not registering it on PyPI
|
||||
|
||||
## Features
|
||||
|
||||
*TODO*
|
||||
|
||||
## Installation
|
||||
|
||||
*TODO*
|
||||
|
||||
## Documentation
|
||||
|
||||
*TODO*
|
||||
|
||||
## Versions
|
||||
|
||||
*TODO*
|
||||
|
||||
## TODO
|
||||
|
||||
* Finish README.md
|
||||
* Write tests
|
||||
* Add comments to code
|
||||
* Separate branches
|
||||
* Working CI
|
||||
* Fix bugs
|
||||
@@ -1,8 +0,0 @@
|
||||
import logging
|
||||
from bot import Bot
|
||||
|
||||
logging.basicConfig(format="[%(asctime)s][%(levelname)s][%(module)s] %(message)s", level=logging.INFO)
|
||||
|
||||
bot = Bot("test-app", "0.1-alpha", alias="|")
|
||||
bot.log_calls = True
|
||||
bot.start()
|
||||
@@ -0,0 +1 @@
|
||||
from .bot import Bot
|
||||
@@ -70,7 +70,7 @@ class Bot(object):
|
||||
self.alias = alias # can call bot with {alias}{command_name}
|
||||
self.any_mention = False # bot mention can be anywhere
|
||||
self.log_calls = False
|
||||
self.guild_logs_file = "guilds.log"
|
||||
self.guild_logs_file = "../guilds.log"
|
||||
self.enforce_write_permission = True
|
||||
self.lower_command_names = True
|
||||
self.game_change_delay = 10
|
||||
@@ -197,6 +197,7 @@ class Bot(object):
|
||||
f" #{message.channel} in server '{message.guild}'")
|
||||
return
|
||||
await command.compute(self.client, message, *command_args)
|
||||
break
|
||||
|
||||
async def on_guild_join(self, guild: discord.guild):
|
||||
if self.guild_logs_file is not None:
|
||||
@@ -210,7 +211,7 @@ class Bot(object):
|
||||
pass
|
||||
|
||||
def register_command(self, regex: str, compute: CommandFunction, help_short: str, help_long: str):
|
||||
self.__commands += [Command(regex, compute, help_short, help_long)]
|
||||
self.__commands.insert(0, Command(regex, compute, help_short, help_long))
|
||||
|
||||
def start(self):
|
||||
logging.info(f"Current PID: {os.getpid()}")
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user