add .send_action utils functions to Server, Channel and User

This commit is contained in:
jesopo 2020-03-23 15:27:22 +00:00
parent 40f111f78f
commit 223c2c88ff
3 changed files with 8 additions and 0 deletions

View file

@ -210,6 +210,8 @@ class Channel(IRCObject.Object):
def send_message(self, text: str, tags: dict={}):
return self.server.send_message(self.name, text, tags=tags)
def send_action(self, text: str, tags: dict={}):
return self.server.send_action(self.name, text, tags=tags)
def send_notice(self, text: str, tags: dict={}):
return self.server.send_notice(self.name, text, tags=tags)
def send_tagmsg(self, tags: dict):

View file

@ -390,6 +390,10 @@ class Server(IRCObject.Object):
def send_message(self, target: str, message: str, tags: dict={}
) -> typing.Optional[IRCLine.SentLine]:
return self.send(self._line("PRIVMSG", [target, message], tags=tags))
def send_action(self, target: str, message: str, tags: dict={}
) -> typing.Optional[IRCLine.SentLine]:
return self.send(self._line("PRIVMSG",
[target, f"\x01ACTION {message}\x01"], tags=tags))
def send_notice(self, target: str, message: str, tags: dict={}
) -> typing.Optional[IRCLine.SentLine]:

View file

@ -77,6 +77,8 @@ class User(IRCObject.Object):
def send_message(self, message: str, tags: dict={}):
self.server.send_message(self.nickname, message, tags=tags)
def send_action(self, message: str, tags: dict={}):
self.server.send_action(self.nickname, message, tags=tags)
def send_notice(self, text: str, tags: dict={}):
self.server.send_notice(self.nickname, text, tags=tags)
def send_ctcp_response(self, command: str, args: str):