Example #1
0
func (pg *CmdPlugin) writeIn(p *proto.Packet) error {
	data, err := p.Encode()
	if err != nil {
		return err
	}
	_, err = pg.stdinBuffer.Write(data)
	if err != nil {
		return err
	}
	err = pg.stdinBuffer.WriteByte('\n')
	if err != nil {
		return err
	}
	return pg.stdinBuffer.Flush()
}
Example #2
0
func (s *Session) handleRoomStatusCommand(cmd *proto.RoomStatusCommand, id int) error {
	var reply proto.RoomStatusReply
	reply.Nick = s.bot.nick
	reply.RoomIsPrivate = s.bot.isPrivate
	reply.RoomName = s.bot.roomName
	data, err := json.Marshal(reply)
	if err != nil {
		return err
	}
	var packet proto.Packet
	packet.Data = data
	packet.ID = id
	packet.Type = proto.RoomStatusReplyType
	if err := s.plugin.Send(&packet); err != nil {
		return err
	}
	return nil
}