Comments (2)
This does appear to be an actual issue; the regex used for joining quoted arguments together doesn't handle escapes. Let me see if I can quickly fix this.
from starrypy3k.
Thanks for the quick response! I came to the same conclusion and gave shlex a shot. It seems to work really well, but I'm not familiar enough with the project to know if adding it would have unintended consequences.
Here's a diff:
diff --git a/plugins/command_dispatcher.py b/plugins/command_dispatcher.py
index bc356c3..3629ac3 100644
--- a/plugins/command_dispatcher.py
+++ b/plugins/command_dispatcher.py
@@ -13,9 +13,10 @@ Updated for release: kharidiron
import asyncio
import packets
+import shlex
from base_plugin import BasePlugin
-from utilities import extractor, get_syntax, send_message
+from utilities import get_syntax, send_message
from data_parser import ChatSent
from pparser import build_packet
@@ -55,8 +56,8 @@ class CommandDispatcher(BasePlugin):
full = build_packet(packets.packets['chat_sent'], pkt)
yield from connection.client_raw_write(full)
return False
- to_parse = data['parsed']['message'][len(
- self.plugin_config.command_prefix):].split()
+ to_parse = shlex.split(data['parsed']['message'][len(
+ self.plugin_config.command_prefix):])
try:
command = to_parse[0]
@@ -140,8 +141,7 @@ class CommandDispatcher(BasePlugin):
General Exception error as a last-resort catch-all.
"""
try:
- yield from self.commands[command](extractor(to_parse),
- connection)
+ yield from self.commands[command](to_parse,connection)
except SyntaxWarning as e:
self._send_syntax_error(command, e, connection)
except NameError as e:
diff --git a/utilities.py b/utilities.py
index c0a13e7..bbda05b 100644
--- a/utilities.py
+++ b/utilities.py
@@ -235,18 +235,6 @@ def read_signed_vlq(reader):
return -((v >> 1) + 1), d
-def extractor(*args):
- """
- Extracts quoted arguments and puts them as a single argument in the
- passed iterator.
- """
- # It's not elegant, but it's the best way to do it as far as I can tell.
- # My regex-fu isn't strong though, so if someone can come up with a
- # better way, great.
- x = re.split(r"(?:([^\"]\S*)|\"(.+?)\")\s*", " ".join(*args))
- return [x for x in filter(None, x)]
-
-
@asyncio.coroutine
def read_packet(reader, direction):
"""
from starrypy3k.
Related Issues (20)
- option to disable IRC plugin HOT 1
- bounties
- StarryPy3k Discord HOT 1
- No permissions / CPU at 100%
- Discord eventually kills the Discord Bot
- Discord bot going afterline after a while HOT 1
- StarryPy3k does not work in 1.3.4 (745) version HOT 1
- Starbound 1.4 HOT 2
- Error starting Discord bot : login() got an unexpected keyword argument 'loop' HOT 4
- starrypy.plugin.discord_bot # Couldn't get staff channel! Reports will be sent to the main channel. HOT 1
- Bot now stops working. Joins and disconnects with errors HOT 1
- Update to Python 3.8 HOT 8
- discord bot not responding to discord input HOT 1
- Permissions/ranks/roles do not work
- use discord.py 1.7.3 HOT 1
- Maintainership of this project? HOT 2
- Provide official docker builds HOT 1
- Replace Shelf/Cupboard with other database HOT 2
- docker-start.sh : can't find diredctory or file HOT 1
- Feature Request - GUI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from starrypy3k.