Procházet zdrojové kódy

Support reply-nick syntax for all commands; support unspaced form.

tags/v0.2
Ben Kurtovic před 8 roky
rodič
revize
a8e431e806
3 změnil soubory, kde provedl 15 přidání a 5 odebrání
  1. +0
    -4
      earwigbot/commands/link.py
  2. +1
    -1
      earwigbot/irc/connection.py
  3. +14
    -0
      earwigbot/irc/data.py

+ 0
- 4
earwigbot/commands/link.py Zobrazit soubor

@@ -44,10 +44,6 @@ class Link(Command):
self.reply(data, links.encode("utf8"))

elif data.command == "link":
if data.args and data.args[0].startswith(">"):
nick = data.args.pop(0)[1:]
data._nick = nick # XXX: hack - should be generally supported

if not data.args:
if data.chan in self.last:
links = u" , ".join(self.parse_line(self.last[data.chan]))


+ 1
- 1
earwigbot/irc/connection.py Zobrazit soubor

@@ -172,7 +172,7 @@ class IRCConnection(object):
if data.is_private:
self.say(data.chan, msg, hidelog)
else:
msg = "\x02{0}\x0F: {1}".format(data.nick, msg)
msg = "\x02{0}\x0F: {1}".format(data.reply_nick, msg)
self.say(data.chan, msg, hidelog)

def action(self, target, msg, hidelog=False):


+ 14
- 0
earwigbot/irc/data.py Zobrazit soubor

@@ -52,6 +52,7 @@ class Data(object):
"""Parse a line from IRC into its components as instance attributes."""
sender = re.findall(r":(.*?)!(.*?)@(.*?)\Z", self.line[0])[0]
self._nick, self._ident, self._host = sender
self._reply_nick = self._nick
self._chan = self.line[2]

if msgtype == "PRIVMSG":
@@ -103,6 +104,14 @@ class Data(object):
except IndexError:
pass

# e.g. "!command>user arg1 arg2"
if ">" in self.command:
self._command, self._reply_nick = self.command.split(">", 1)

# e.g. "!command >user arg1 arg2"
if self.args and self.args[0].startswith(">"):
self._reply_nick = self.args.pop(0)[1:]

def _parse_kwargs(self):
"""Parse keyword arguments embedded in self.args.

@@ -152,6 +161,11 @@ class Data(object):
return self._host

@property
def reply_nick(self):
"""Nickname of the person to reply to. Sender by default."""
return self._reply_nick

@property
def msg(self):
"""Text of the sent message, if it is a message, else ``None``."""
return self._msg


Načítá se…
Zrušit
Uložit