예제 #1
0
파일: client.py 프로젝트: alex108/tama
 def notice(self, target: str, message: str) -> None:
     self._outbound_queue.put_nowait(
         IRCMessage(
             command="NOTICE",
             middle=(target, ),
             trailing=message,
         ))
예제 #2
0
파일: client.py 프로젝트: alex108/tama
 def privmsg(self, target: str, message: str) -> None:
     self._outbound_queue.put_nowait(
         IRCMessage(
             command="PRIVMSG",
             middle=(target, ),
             trailing=message,
         ))
예제 #3
0
파일: client.py 프로젝트: alex108/tama
 def user(self, username: str, realname: str) -> None:
     self._outbound_queue.put_nowait(
         IRCMessage(
             command="USER",
             middle=(username, "0", "*"),
             trailing=realname,
         ))
예제 #4
0
파일: client.py 프로젝트: alex108/tama
 def handle_server_invite(self, msg: IRCMessage) -> None:
     self.bus.broadcast(
         InvitedEvent(
             client=self,
             who=msg.parse_prefix_as_user(),
             to=msg.trailing,
         ))
예제 #5
0
파일: client.py 프로젝트: alex108/tama
 def handle_server_kick(self, msg: IRCMessage) -> None:
     who = msg.parse_prefix_as_user()
     chan, target, *_ = msg.middle
     if target == self.nickname:
         try:
             self._channel_list.remove(msg.trailing)
         except ValueError:
             getLogger(__name__).error(
                 "Kicked from a channel that was never joined.")
         self.bus.broadcast(
             BotKickedEvent(
                 client=self,
                 channel=chan,
                 who=who,
                 target=target,
                 message=msg.trailing,
             ))
     else:
         self.bus.broadcast(
             ChannelKickedEvent(
                 client=self,
                 channel=chan,
                 who=who,
                 target=target,
                 message=msg.trailing,
             ))
예제 #6
0
파일: client.py 프로젝트: alex108/tama
 def handle_server_notice(self, msg: IRCMessage) -> None:
     # If command param is the client nick, set the user as the location
     who = msg.parse_prefix_as_user()
     where = msg.middle[0]
     if where == self.nickname:
         where = who.nick
     self.bus.broadcast(
         NoticedEvent(
             client=self,
             who=who,
             where=where,
             message=msg.trailing,
         ))
예제 #7
0
파일: client.py 프로젝트: alex108/tama
 def handle_server_join(self, msg: IRCMessage) -> None:
     who = msg.parse_prefix_as_user()
     if who.nick == self.nickname:
         self._channel_list.append(msg.trailing)
         self.bus.broadcast(
             BotJoinedEvent(
                 client=self,
                 channel=msg.trailing,
                 who=who,
             ))
     else:
         self.bus.broadcast(
             ChannelJoinedEvent(
                 client=self,
                 channel=msg.trailing,
                 who=who,
             ))
예제 #8
0
파일: client.py 프로젝트: alex108/tama
 def handle_server_part(self, msg: IRCMessage) -> None:
     who = msg.parse_prefix_as_user()
     if who.nick == self.nickname:
         try:
             self._channel_list.remove(msg.trailing)
         except ValueError:
             getLogger(__name__).error(
                 "Parted a channel that was never joined.")
         self.bus.broadcast(
             BotPartedEvent(
                 client=self,
                 channel=msg.middle[0],
                 who=who,
                 message=msg.trailing,
             ))
     else:
         self.bus.broadcast(
             ChannelPartedEvent(
                 client=self,
                 channel=msg.middle[0],
                 who=who,
                 message=msg.trailing,
             ))
예제 #9
0
파일: client.py 프로젝트: alex108/tama
 async def create(cls, name: str, config: ServerConfig) -> "IRCClient":
     if config.port.startswith("+"):
         secure = True
         port = int(config.port)
     else:
         secure = False
         port = int(config.port)
     stream = await IRCStream.create(config.host, port, secure)
     obj = cls(name, config, stream)
     obj.nick(config.nick)
     obj.user(config.user, config.realname)
     if config.service_auth:
         cmd = config.service_auth.command or "IDENTIFY "
         if config.service_auth.username:
             cmd += config.service_auth.username + " "
         cmd += config.service_auth.password
         obj._on_register.append(
             IRCMessage(
                 command="PRIVMSG",
                 middle=(config.service_auth.service or "NickServ", ),
                 trailing=cmd,
             ))
     return obj
예제 #10
0
파일: client.py 프로젝트: alex108/tama
 def quit(self, reason: str) -> None:
     self._outbound_queue.put_nowait(
         IRCMessage(
             command="QUIT",
             trailing=reason,
         ))
예제 #11
0
파일: client.py 프로젝트: alex108/tama
 def join(self, channel: str) -> None:
     self._outbound_queue.put_nowait(
         IRCMessage(command="JOIN", middle=(channel, )))
예제 #12
0
파일: client.py 프로젝트: alex108/tama
 def pong(self, payload: str) -> None:
     self._outbound_queue.put_nowait(
         IRCMessage(
             command="PONG",
             trailing=payload,
         ))
예제 #13
0
파일: client.py 프로젝트: alex108/tama
 def nick(self, nickname: str) -> None:
     self._outbound_queue.put_nowait(
         IRCMessage(
             command="NICK",
             trailing=nickname,
         ))
예제 #14
0
파일: client.py 프로젝트: alex108/tama
 def handle_server_nick(self, msg: IRCMessage) -> None:
     who = msg.parse_prefix_as_user()
     if who.nick == self.nickname:
         self.nickname = msg.trailing