Use shlex instead of split to split command passed to nemubot

This commit is contained in:
Némunaire 2012-06-29 01:16:06 +02:00
parent 22348e53b5
commit 0f502f5b22
2 changed files with 9 additions and 12 deletions

View File

@ -2,11 +2,12 @@
from datetime import datetime
from datetime import timedelta
import re
import sys
import string
import time
import imp
import re
import shlex
import string
import sys
import time
from credits import Credits
import credits
@ -145,10 +146,6 @@ class Message:
now = datetime.now()
self.send_chn ("%s: j'envoie ce message à %s:%d:%d."%(self.sender, now.hour, now.minute, now.second))
elif re.match(".*qui est ([a-zA-Z0-9_-]+)", messagel) is not None:
result = re.match(".*qui est ([a-zA-Z0-9_-]+).*", self.content)
self.send_chn ("!whois %s"%(result.group(1)))
elif re.match(".*di[st] (a|à) ([a-zA-Z0-9_]+) (.+)$", messagel) is not None:
result = re.match(".*di[st] (a|à) ([a-zA-Z0-9_]+) (qu(e |'))?(.+)$", self.content)
self.send_chn ("%s: %s"%(result.group(2), result.group(5)))
@ -207,7 +204,7 @@ class Message:
#Messages stating with !
elif self.content[0] == '!':
self.mods = mods
self.cmd = self.content[1:].split(' ')
self.cmd = shlex.split(self.content[1:])
if self.cmd[0] == "help":
if len (self.cmd) > 1:
if self.cmd[1] in mods:

View File

@ -1,7 +1,7 @@
import sys
import shlex
import traceback
import imp
import shlex
import sys
import traceback
server = __import__("server")
imp.reload(server)